diff --git a/examples/pom.xml b/examples/pom.xml index f882f1bd03f..6ba67e71f38 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -80,4 +80,27 @@ 2.0.17 + + + google3-local + + + ${project.basedir}/../src/main/java/com/google/genai/interactions/core/http/HttpClient.kt + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + com/google/genai/examples/Interaction* + + + + + + + diff --git a/examples/resources/sample_audio.mp3 b/examples/resources/sample_audio.mp3 new file mode 100644 index 00000000000..68a00666d3f Binary files /dev/null and b/examples/resources/sample_audio.mp3 differ diff --git a/examples/src/main/java/com/google/genai/examples/InteractionBasic.java b/examples/src/main/java/com/google/genai/examples/InteractionBasic.java new file mode 100644 index 00000000000..91f35a10609 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionBasic.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.InteractionBasic" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Unified Gen AI Java SDK to create a basic interaction. */ +public final class InteractionBasic { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("Using Gemini Developer API"); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("Why is the sky blue?")) + .model(Constants.GEMINI_MODEL_NAME) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + // Print the text outputs from the interaction. + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionBasic() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionCreate.java b/examples/src/main/java/com/google/genai/examples/InteractionCreate.java new file mode 100644 index 00000000000..fe420b7944e --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionCreate.java @@ -0,0 +1,104 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.InteractionCreate" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Unified Gen AI Java SDK to create an interaction. */ +public final class InteractionCreate { + public static void main(String[] args) { + // Instantiate the client. The client by default uses the Gemini Developer API. It gets the API + // key from the environment variable `GOOGLE_API_KEY`. Vertex AI API can be used by setting the + // environment variables `GOOGLE_CLOUD_LOCATION` and `GOOGLE_CLOUD_PROJECT`, as well as setting + // `GOOGLE_GENAI_USE_VERTEXAI` to "true". + // + // Note: Some services are only available in a specific API backend (Gemini or Vertex), you will + // get a `UnsupportedOperationException` if you try to use a service that is not available in + // the backend you are using. + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Using Vertex AI"); + } else { + System.out.println("Using Gemini Developer API"); + } + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("What is your name?")) + .model(Constants.GEMINI_MODEL_NAME) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + // Print the text outputs from the interaction. + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionCreate() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionCreateAsync.java b/examples/src/main/java/com/google/genai/examples/InteractionCreateAsync.java new file mode 100644 index 00000000000..fd296d9eab8 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionCreateAsync.java @@ -0,0 +1,115 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionCreateAsync" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.util.concurrent.CompletableFuture; + +/** An example of using the Unified Gen AI Java SDK to create an interaction asynchronously. */ +public final class InteractionCreateAsync { + public static void main(String[] args) { + // Instantiate the client. The client by default uses the Gemini Developer API. It gets the API + // key from the environment variable `GOOGLE_API_KEY`. Vertex AI API can be used by setting the + // environment variables `GOOGLE_CLOUD_LOCATION` and `GOOGLE_CLOUD_PROJECT`, as well as setting + // `GOOGLE_GENAI_USE_VERTEXAI` to "true". + // + // Note: Some services are only available in a specific API backend (Gemini or Vertex), you will + // get a `UnsupportedOperationException` if you try to use a service that is not available in + // the backend you are using. + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Using Vertex AI"); + } else { + System.out.println("Using Gemini Developer API"); + } + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("What is your name?")) + .model(Constants.GEMINI_MODEL_NAME) + .build(); + + CompletableFuture interactionFuture = + client.async.interactions.create(CreateInteractionRequestBody.of(params)) + .body() + .thenApply( + response -> + response + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction"))); + + interactionFuture + .thenAccept( + interaction -> { + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + // Print the text outputs from the interaction. + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + }) + .join(); + } + + private InteractionCreateAsync() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionCreateAsyncStreaming.java b/examples/src/main/java/com/google/genai/examples/InteractionCreateAsyncStreaming.java new file mode 100644 index 00000000000..d0381471a1b --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionCreateAsyncStreaming.java @@ -0,0 +1,126 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionCreateAsyncStreaming" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.InteractionSSEEvent; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.StepDelta; +import com.google.genai.gaos.models.interactions.StepDeltaData; +import com.google.genai.gaos.models.interactions.TextDelta; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.util.concurrent.CompletableFuture; +import org.reactivestreams.Subscriber; +import org.reactivestreams.Subscription; + +/** + * An example of using the Unified Gen AI Java SDK to create a streaming interaction asynchronously. + */ +public final class InteractionCreateAsyncStreaming { + public static void main(String[] args) { + // Instantiate the client. The client by default uses the Gemini Developer API. It gets the API + // key from the environment variable `GOOGLE_API_KEY`. Vertex AI API can be used by setting the + // environment variables `GOOGLE_CLOUD_LOCATION` and `GOOGLE_CLOUD_PROJECT`, as well as setting + // `GOOGLE_GENAI_USE_VERTEXAI` to "true". + // + // Note: Some services are only available in a specific API backend (Gemini or Vertex), you will + // get a `UnsupportedOperationException` if you try to use a service that is not available in + // the backend you are using. + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Using Vertex AI"); + } else { + System.out.println("Using Gemini Developer API"); + } + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("Tell me a story in 300 words.")) + .model(Constants.GEMINI_MODEL_NAME) + .stream(true) + .build(); + + System.out.println("Streaming response:"); + CompletableFuture onCompleteFuture = new CompletableFuture<>(); + client.async.interactions.create(CreateInteractionRequestBody.of(params)) + .subscribe(new Subscriber() { + @Override + public void onSubscribe(Subscription s) { + s.request(Long.MAX_VALUE); + } + + @Override + public void onNext(InteractionSSEStreamEvent streamEvent) { + InteractionSSEEvent event = streamEvent.data(); + if (event.value() instanceof StepDelta) { + StepDelta stepDelta = (StepDelta) event.value(); + StepDeltaData data = stepDelta.delta(); + if (data.value() instanceof TextDelta) { + TextDelta textDelta = (TextDelta) data.value(); + System.out.print(textDelta.text()); + System.out.flush(); + } + } + } + + @Override + public void onError(Throwable t) { + onCompleteFuture.completeExceptionally(t); + } + + @Override + public void onComplete() { + onCompleteFuture.complete(null); + } + }); + + // Wait for the stream to complete. + onCompleteFuture.join(); + System.out.println(); + + client.close(); + } + + private InteractionCreateAsyncStreaming() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionCreateStreaming.java b/examples/src/main/java/com/google/genai/examples/InteractionCreateStreaming.java new file mode 100644 index 00000000000..54fa674c4f8 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionCreateStreaming.java @@ -0,0 +1,105 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionCreateStreaming" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.InteractionSSEEvent; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.StepDelta; +import com.google.genai.gaos.models.interactions.StepDeltaData; +import com.google.genai.gaos.models.interactions.TextDelta; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.gaos.models.operations.CreateInteractionResponse; +import com.google.genai.gaos.utils.EventStream; + +/** + * An example of using the Unified Gen AI Java SDK to create a streaming interaction synchronously. + */ +public final class InteractionCreateStreaming { + public static void main(String[] args) throws Exception { + // Instantiate the client. The client by default uses the Gemini Developer API. It gets the API + // key from the environment variable `GOOGLE_API_KEY`. Vertex AI API can be used by setting the + // environment variables `GOOGLE_CLOUD_LOCATION` and `GOOGLE_CLOUD_PROJECT`, as well as setting + // `GOOGLE_GENAI_USE_VERTEXAI` to "true". + // + // Note: Some services are only available in a specific API backend (Gemini or Vertex), you will + // get a `UnsupportedOperationException` if you try to use a service that is not available in + // the backend you are using. + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Using Vertex AI"); + } else { + System.out.println("Using Gemini Developer API"); + } + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("Tell me a story in 300 words.")) + .model(Constants.GEMINI_MODEL_NAME) + .stream(true) + .build(); + + CreateInteractionResponse response = + client.interactions.create(CreateInteractionRequestBody.of(params)); + + try (EventStream eventStream = response.events()) { + System.out.println("Streaming response:"); + for (InteractionSSEStreamEvent streamEvent : eventStream) { + InteractionSSEEvent event = streamEvent.data(); + if (event.value() instanceof StepDelta) { + StepDelta stepDelta = (StepDelta) event.value(); + StepDeltaData data = stepDelta.delta(); + if (data.value() instanceof TextDelta) { + TextDelta textDelta = (TextDelta) data.value(); + System.out.print(textDelta.text()); + System.out.flush(); + } + } + } + System.out.println(); + } + } + + private InteractionCreateStreaming() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionDeepResearch.java b/examples/src/main/java/com/google/genai/examples/InteractionDeepResearch.java new file mode 100644 index 00000000000..92fc94dd121 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionDeepResearch.java @@ -0,0 +1,175 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

Deep Research is currently only available on Vertex AI. + * + *

1. Setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

2. Set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=global + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

3. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionDeepResearch" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.CreateAgentInteraction; +import com.google.genai.gaos.models.interactions.ErrorEvent; +import com.google.genai.gaos.models.interactions.InteractionCompletedEvent; +import com.google.genai.gaos.models.interactions.InteractionCreatedEvent; +import com.google.genai.gaos.models.interactions.InteractionSSEEvent; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.models.interactions.InteractionStatusUpdate; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.StepDelta; +import com.google.genai.gaos.models.interactions.StepDeltaData; +import com.google.genai.gaos.models.interactions.StepStart; +import com.google.genai.gaos.models.interactions.StepStop; +import com.google.genai.gaos.models.interactions.TextDelta; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.gaos.models.operations.CreateInteractionResponse; +import com.google.genai.gaos.models.operations.GetInteractionByIdResponse; +import com.google.genai.gaos.utils.EventStream; +import java.util.concurrent.atomic.AtomicReference; + +/** + * An example of using the Unified Gen AI Java SDK to run a Deep Research interaction on Vertex AI. + */ +public final class InteractionDeepResearch { + public static void main(String[] args) throws Exception { + // Instantiate the client. Deep Research requires Vertex AI. + // Ensure GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION=global, and + // GOOGLE_GENAI_USE_VERTEXAI=true are set in your environment. + Client client = new Client(); + + if (!client.vertexAI()) { + System.err.println("Deep Research is only supported on Vertex AI. " + + "Please set GOOGLE_GENAI_USE_VERTEXAI=true."); + return; + } + + System.out.println( + "Using Vertex AI Project: " + (client.project() != null ? client.project() : "unknown")); + + CreateAgentInteraction params = + CreateAgentInteraction.builder() + .agent("deep-research-pro-preview-12-2025") + .input(InteractionsInput.of("I want to learn more about the history of Hadrian's Wall")) + .background(true) + .stream(true) + .build(); + + AtomicReference interactionId = new AtomicReference<>(); + + System.out.println("--- Starting Deep Research Interaction ---"); + + CreateInteractionResponse createResponse = + client.interactions.create() + .apiVersion("v1beta1") + .body(CreateInteractionRequestBody.of(params)) + .call(); + + try (EventStream eventStream = createResponse.events()) { + // We consume the first few events to capture the Interaction ID and see progress. + for (InteractionSSEStreamEvent streamEvent : eventStream) { + InteractionSSEEvent event = streamEvent.data(); + if (event.value() instanceof InteractionCreatedEvent) { + InteractionCreatedEvent createdEvent = (InteractionCreatedEvent) event.value(); + String id = createdEvent.interaction().id(); + interactionId.set(id); + System.out.println("Started Interaction ID: " + id); + } + String eventType = "unknown"; + if (event.value() instanceof InteractionCreatedEvent) { + eventType = "interaction.created"; + } else if (event.value() instanceof InteractionCompletedEvent) { + eventType = "interaction.completed"; + } else if (event.value() instanceof InteractionStatusUpdate) { + eventType = "interaction.status_update"; + } else if (event.value() instanceof StepStart) { + eventType = "step.start"; + } else if (event.value() instanceof StepDelta) { + eventType = "step.delta"; + } else if (event.value() instanceof StepStop) { + eventType = "step.stop"; + } else if (event.value() instanceof ErrorEvent) { + eventType = "error"; + } + + System.out.println("Event type: " + eventType); + + // Stop consuming after capturing the ID or if the stream is complete + if (interactionId.get() != null) { + break; + } + } + } + + String id = interactionId.get(); + if (id == null) { + System.err.println("Failed to capture interaction ID."); + return; + } + + // Deep research can take a long time. In a real application, you might poll or resume later. + // Here we resume the stream to wait for more output. + System.out.println("\n--- Resuming Interaction: " + id + " ---"); + GetInteractionByIdResponse getResponse = + client.interactions.get( + com.google.genai.gaos.models.operations.GetInteractionByIdRequest.builder() + .apiVersion("v1beta1") + .id(id) + .stream(true) + .build()); + + try (EventStream eventStream = getResponse.events()) { + for (InteractionSSEStreamEvent streamEvent : eventStream) { + InteractionSSEEvent event = streamEvent.data(); + if (event.value() instanceof InteractionStatusUpdate) { + InteractionStatusUpdate statusUpdate = (InteractionStatusUpdate) event.value(); + System.out.println( + "\n[Status update: " + statusUpdate.status().value() + "]"); + } else if (event.value() instanceof StepDelta) { + StepDelta stepDelta = (StepDelta) event.value(); + StepDeltaData data = stepDelta.delta(); + if (data.value() instanceof TextDelta) { + TextDelta textDelta = (TextDelta) data.value(); + System.out.print(textDelta.text()); + } else { + // If it's a content delta but doesn't have text (e.g. tool call + // or thought), print the type. + System.out.println("\n[Agent Activity]: " + data.value().getClass().getSimpleName()); + } + } + } + System.out.println(); + } + } + + private InteractionDeepResearch() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingClientState.java b/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingClientState.java new file mode 100644 index 00000000000..3d243985935 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingClientState.java @@ -0,0 +1,222 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionFunctionCallingClientState" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Function; +import com.google.genai.gaos.models.interactions.FunctionCallStep; +import com.google.genai.gaos.models.interactions.FunctionResultStep; +import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.Tool; +import com.google.genai.gaos.models.interactions.UserInputStep; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** An example of using the Unified Gen AI Java SDK to perform client-side function calling. */ +public final class InteractionFunctionCallingClientState { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("Using Gemini Developer API"); + + // 1. Define the function (tool) + Map attendeesSchema = new HashMap<>(); + attendeesSchema.put("type", "array"); + attendeesSchema.put("items", ImmutableMap.of("type", "string")); + attendeesSchema.put("description", "List of people attending the meeting."); + + Map dateSchema = new HashMap<>(); + dateSchema.put("type", "string"); + dateSchema.put("description", "Date of the meeting (e.g., 2024-07-29)"); + + Map timeSchema = new HashMap<>(); + timeSchema.put("type", "string"); + timeSchema.put("description", "Time of the meeting (e.g., 15:00)"); + + Map topicSchema = new HashMap<>(); + topicSchema.put("type", "string"); + topicSchema.put("description", "The subject or topic of the meeting."); + + Map properties = new HashMap<>(); + properties.put("attendees", attendeesSchema); + properties.put("date", dateSchema); + properties.put("time", timeSchema); + properties.put("topic", topicSchema); + + Map parametersSchema = new HashMap<>(); + parametersSchema.put("type", "object"); + parametersSchema.put("properties", properties); + parametersSchema.put("required", Arrays.asList("attendees", "date", "time", "topic")); + + Function function = + Function.builder() + .name("schedule_meeting") + .description("Schedules a meeting with specified attendees at a given time and date.") + .parameters(parametersSchema) + .build(); + + // 2. Initialize conversation history + List conversationHistory = new ArrayList<>(); + conversationHistory.add( + Step.of( + UserInputStep.builder() + .content( + ImmutableList.of( + Content.of( + TextContent.builder() + .text( + "Schedule a meeting for 2025-11-01 at 10 am with Peter and Amir" + + " about the Next Gen API") + .build()))) + .build())); + + // 3. First turn: Model decides to call the function + CreateModelInteraction params = + CreateModelInteraction.builder() + .model(Constants.GEMINI_MODEL_NAME) + .input(InteractionsInput.ofStep(conversationHistory)) + .tools(ImmutableList.of(Tool.of(function))) + .build(); + + Interaction response = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + String functionCallId = null; + String functionName = null; + + if (response.steps().isPresent()) { + List steps = response.steps().get(); + for (Step step : steps) { + if (step.value() instanceof FunctionCallStep) { + FunctionCallStep functionCall = (FunctionCallStep) step.value(); + functionCallId = functionCall.id(); + functionName = functionCall.name(); + System.out.println("Model requested function call: " + functionName); + System.out.println("Arguments: " + functionCall.arguments()); + } else if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent( + contents -> { + for (Content output : contents) { + if (output.value() instanceof TextContent) { + TextContent text = (TextContent) output.value(); + System.out.println("Output Text: " + text.text()); + } + } + }); + } + } + + // Add model response back to history + for (Step step : steps) { + conversationHistory.add(step); + } + } + + // 4. Second turn: Send the function result back to the model + if (functionCallId != null) { + System.out.println("Sending function result back..."); + + FunctionResultStep functionResult = + FunctionResultStep.builder() + .callId(functionCallId) + .name(functionName) + .result(FunctionResultStepResultUnion.of("Meeting scheduled successfully.")) + .build(); + + // Create a step with function result + conversationHistory.add(Step.of(functionResult)); + + CreateModelInteraction followUpParams = + CreateModelInteraction.builder() + .model(Constants.GEMINI_MODEL_NAME) + .input(InteractionsInput.ofStep(conversationHistory)) + .build(); + + Interaction followUpResponse = + client.interactions.create(CreateInteractionRequestBody.of(followUpParams)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create follow up interaction")); + + System.out.println("Final response status: " + followUpResponse.status()); + followUpResponse.steps().ifPresent(followUpSteps -> { + for (Step step : followUpSteps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent( + contents -> { + for (Content output : contents) { + if (output.value() instanceof TextContent) { + TextContent text = (TextContent) output.value(); + System.out.println("Final Output: " + text.text()); + } + } + }); + } + } + }); + } else { + System.out.println("No function call requested by the model."); + } + } + + private InteractionFunctionCallingClientState() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingServerState.java b/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingServerState.java new file mode 100644 index 00000000000..9c7cee94379 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingServerState.java @@ -0,0 +1,204 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionFunctionCallingServerState" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Function; +import com.google.genai.gaos.models.interactions.FunctionCallStep; +import com.google.genai.gaos.models.interactions.FunctionResultStep; +import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.Tool; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * An example of using the Interactions API for multi-turn function calling where the state is + * managed by the server. + */ +public final class InteractionFunctionCallingServerState { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("Using Gemini Developer API"); + + // 1. Define the function (tool) + Map attendeesSchema = new HashMap<>(); + attendeesSchema.put("type", "array"); + attendeesSchema.put("items", ImmutableMap.of("type", "string")); + attendeesSchema.put("description", "List of people attending the meeting."); + + Map dateSchema = new HashMap<>(); + dateSchema.put("type", "string"); + dateSchema.put("description", "Date of the meeting (e.g., 2024-07-29)"); + + Map timeSchema = new HashMap<>(); + timeSchema.put("type", "string"); + timeSchema.put("description", "Time of the meeting (e.g., 15:00)"); + + Map topicSchema = new HashMap<>(); + topicSchema.put("type", "string"); + topicSchema.put("description", "The subject or topic of the meeting."); + + Map properties = new HashMap<>(); + properties.put("attendees", attendeesSchema); + properties.put("date", dateSchema); + properties.put("time", timeSchema); + properties.put("topic", topicSchema); + + Map parametersSchema = new HashMap<>(); + parametersSchema.put("type", "object"); + parametersSchema.put("properties", properties); + parametersSchema.put("required", Arrays.asList("attendees", "date", "time", "topic")); + + Function function = + Function.builder() + .name("schedule_meeting") + .description("Schedules a meeting with specified attendees at a given time and date.") + .parameters(parametersSchema) + .build(); + + // 2. First turn: Model decides to call the function + CreateModelInteraction params = + CreateModelInteraction.builder() + .input( + InteractionsInput.of( + "Schedule a meeting for 2025-11-01 at 10 am with Peter and Amir about the Next Gen" + + " API")) + .model(Constants.GEMINI_MODEL_NAME) + .tools(ImmutableList.of(Tool.of(function))) + .build(); + + Interaction response = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + String functionCallId = null; + String functionName = null; + + if (response.steps().isPresent()) { + List steps = response.steps().get(); + for (Step step : steps) { + if (step.value() instanceof FunctionCallStep) { + FunctionCallStep functionCall = (FunctionCallStep) step.value(); + functionCallId = functionCall.id(); + functionName = functionCall.name(); + System.out.println("Model requested function call: " + functionName); + System.out.println("Arguments: " + functionCall.arguments()); + } else if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent( + contents -> { + for (Content output : contents) { + if (output.value() instanceof TextContent) { + TextContent text = (TextContent) output.value(); + System.out.println("Output Text: " + text.text()); + } + } + }); + } + } + } + + // 3. Second turn: Send the function result back to the model + if (functionCallId != null) { + System.out.println("Sending function result back..."); + + FunctionResultStep functionResult = + FunctionResultStep.builder() + .callId(functionCallId) + .name(functionName) + .result(FunctionResultStepResultUnion.of("Meeting scheduled successfully.")) + .build(); + + CreateModelInteraction followUpParams = + CreateModelInteraction.builder() + .model(Constants.GEMINI_MODEL_NAME) + .previousInteractionId(response.id().orElse("")) + .input(InteractionsInput.ofStep(ImmutableList.of(Step.of(functionResult)))) + .build(); + + Interaction followUpResponse = + client.interactions.create(CreateInteractionRequestBody.of(followUpParams)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create follow up interaction")); + + System.out.println("Final response status: " + followUpResponse.status()); + followUpResponse.steps().ifPresent(followUpSteps -> { + for (Step step : followUpSteps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent( + contents -> { + for (Content output : contents) { + if (output.value() instanceof TextContent) { + TextContent text = (TextContent) output.value(); + System.out.println("Final Output: " + text.text()); + } + } + }); + } + } + }); + } else { + System.out.println("No function call requested by the model."); + } + } + + private InteractionFunctionCallingServerState() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionGet.java b/examples/src/main/java/com/google/genai/examples/InteractionGet.java new file mode 100644 index 00000000000..ff6fbcf21c6 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionGet.java @@ -0,0 +1,105 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.InteractionGet" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Unified Gen AI Java SDK to retrieve an interaction. */ +public final class InteractionGet { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("Using Gemini Developer API"); + + // First, create an interaction to get an ID. + CreateModelInteraction createParams = + CreateModelInteraction.builder() + .input(InteractionsInput.of("Why is the sky blue?")) + .model(Constants.GEMINI_MODEL_NAME) + .build(); + + Interaction createdInteraction = + client.interactions.create(CreateInteractionRequestBody.of(createParams)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + String id = createdInteraction.id().orElseThrow(() -> new RuntimeException("No ID returned")); + System.out.println("Created Interaction ID: " + id); + + // Now, retrieve the interaction using the ID. + Interaction retrievedInteraction = + client.interactions.get(new com.google.genai.gaos.models.operations.GetInteractionByIdRequest(id)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to retrieve interaction")); + System.out.println("Retrieved Interaction ID: " + retrievedInteraction.id().orElse("")); + System.out.println("Status: " + retrievedInteraction.status()); + + // Print the text outputs from the retrieved interaction. + retrievedInteraction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionGet() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndAudio.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndAudio.java new file mode 100644 index 00000000000..f06705d351a --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndAudio.java @@ -0,0 +1,113 @@ +/* + * 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. + */ +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionMultimodalInputTextAndAudio" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.AudioContent; +import com.google.genai.gaos.models.interactions.AudioContentMimeType; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Base64; +import java.util.List; + +/** Example of using the Interactions API with multimodal input (text and audio). */ +public final class InteractionMultimodalInputTextAndAudio { + + private InteractionMultimodalInputTextAndAudio() {} + + private static void createInteractions(Client client) { + String base64Audio; + try { + base64Audio = Base64.getEncoder().encodeToString( + Files.readAllBytes(Paths.get("./resources/sample_audio.mp3")) + ); + } catch (IOException e) { + throw new RuntimeException("Failed to read audio file", e); + } + + Content textContent = + Content.of(TextContent.builder().text("Summarize this audio clip.").build()); + Content audioContent = + Content.of( + AudioContent.builder() + .data(base64Audio) + .mimeType(AudioContentMimeType.AUDIO_MP3) + .build()); + + List contents = ImmutableList.of(textContent, audioContent); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .model(Constants.GEMINI_3_5_FLASH_MODEL_NAME) + .input(InteractionsInput.ofContent(contents)) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + interaction.steps().ifPresent(steps -> { + for (int i = 0; i < steps.size(); i++) { + System.out.println("Step " + (i + 1) + ": " + steps.get(i)); + } + }); + } + + public static void main(String[] args) throws Exception { + Client client = new Client(); + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + createInteractions(client); + } +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndImage.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndImage.java new file mode 100644 index 00000000000..8de52554893 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndImage.java @@ -0,0 +1,113 @@ +/* + * 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. + */ +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionMultimodalInputTextAndImage" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.ImageContent; +import com.google.genai.gaos.models.interactions.ImageContentMimeType; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Base64; +import java.util.List; + +/** Example of using the Interactions API with multimodal input (text and image). */ +public final class InteractionMultimodalInputTextAndImage { + + private static void createInteractions(Client client) { + String base64Image; + try { + base64Image = Base64.getEncoder().encodeToString( + Files.readAllBytes(Paths.get("./resources/shapes.jpg")) + ); + } catch (IOException e) { + throw new RuntimeException("Failed to read image file", e); + } + + Content textContent = + Content.of(TextContent.builder().text("What is shown in this image?").build()); + Content imageContent = + Content.of( + ImageContent.builder() + .data(base64Image) + .mimeType(ImageContentMimeType.IMAGE_JPEG) + .build()); + + List contents = ImmutableList.of(textContent, imageContent); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .model(Constants.GEMINI_3_5_FLASH_MODEL_NAME) + .input(InteractionsInput.ofContent(contents)) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + interaction.steps().ifPresent(steps -> { + for (int i = 0; i < steps.size(); i++) { + System.out.println("Step " + (i + 1) + ": " + steps.get(i)); + } + }); + } + + public static void main(String[] args) throws Exception { + Client client = new Client(); + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + createInteractions(client); + } + + private InteractionMultimodalInputTextAndImage() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java new file mode 100644 index 00000000000..91afc30dcfe --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionMultimodalResponseAudio" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.GenerationConfig; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ResponseModality; +import com.google.genai.gaos.models.interactions.SpeechConfig; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.util.Arrays; + +/** Example of generating audio using the Interactions API. */ +public final class InteractionMultimodalResponseAudio { + + private static void createInteractions(Client client) { + + SpeechConfig speechConfig = SpeechConfig.builder().voice("achernar").language("en-US").build(); + + GenerationConfig generationConfig = + GenerationConfig.builder().speechConfig(ImmutableList.of(speechConfig)).build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .model("gemini-2.5-flash-preview-tts") + .responseModalities(ImmutableList.of(ResponseModality.AUDIO)) + .generationConfig(generationConfig) + .input(InteractionsInput.of("Say cheerfully: Have a wonderful day!")) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + interaction.steps().ifPresent(steps -> { + int i = 1; + for (Step step : steps) { + System.out.println("Output " + i + ": " + step); + i++; + } + }); + } + + public static void main(String[] args) throws Exception { + Client client = new Client(); + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + createInteractions(client); + } + + private InteractionMultimodalResponseAudio() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java new file mode 100644 index 00000000000..1c1498202fb --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java @@ -0,0 +1,114 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionMultimodalResponseAudioWithGenerateContent" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.JsonSerializable; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.GenerationConfig; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ResponseModality; +import com.google.genai.gaos.models.interactions.SpeechConfig; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.types.GenerateContentConfig; +import com.google.genai.types.GenerateContentResponse; + +/** + * An example of using the Unified Gen AI Java SDK to create an interaction with audio response and + * generate content with audio response. + */ +public final class InteractionMultimodalResponseAudioWithGenerateContent { + public static void main(String[] args) throws Exception { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("[Interactions] Start interactions multimodal response audio"); + + SpeechConfig speechConfig = SpeechConfig.builder().voice("achernar").language("en-US").build(); + + GenerationConfig generationConfig = + GenerationConfig.builder().speechConfig(ImmutableList.of(speechConfig)).build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .model("gemini-2.5-flash-preview-tts") + .responseModalities(ImmutableList.of(ResponseModality.AUDIO)) + .generationConfig(generationConfig) + .input(InteractionsInput.of("Say cheerfully: Have a wonderful day!")) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + interaction.steps().ifPresent(steps -> { + int stepIndex = 1; + for (Step step : steps) { + System.out.println("Step " + stepIndex + ": " + step); + stepIndex++; + } + }); + + System.out.println("[Generate Content] Start generate content"); + GenerateContentConfig config = + GenerateContentConfig.builder().responseModalities(ImmutableList.of("AUDIO")).build(); + + GenerateContentResponse generateContentResponse = + client.models.generateContent( + "gemini-2.5-flash-preview-tts", "Say cheerfully: Have a wonderful day!", config); + + System.out.println( + "Generate Content response: " + JsonSerializable.toJsonString(generateContentResponse)); + } + + private InteractionMultimodalResponseAudioWithGenerateContent() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImage.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImage.java new file mode 100644 index 00000000000..bf55458539d --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImage.java @@ -0,0 +1,88 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionMultimodalResponseImage" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ResponseModality; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.util.Arrays; + +/** Example of generating an image using the Interactions API. */ +public class InteractionMultimodalResponseImage { + + private static void createInteractions(Client client) { + + CreateModelInteraction params = + CreateModelInteraction.builder() + .model("gemini-2.5-flash-image") + .responseModalities(Arrays.asList(ResponseModality.IMAGE)) + .input(InteractionsInput.of("Generate an image of a futuristic cityscape at sunset.")) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + interaction.steps().ifPresent(steps -> { + int i = 1; + for (Step step : steps) { + System.out.println("Output " + i + ": " + step); + i++; + } + }); + } + + public static void main(String[] args) throws Exception { + Client client = new Client(); + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + createInteractions(client); + } + + private InteractionMultimodalResponseImage() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImageWithGenerateContent.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImageWithGenerateContent.java new file mode 100644 index 00000000000..72d202759e6 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImageWithGenerateContent.java @@ -0,0 +1,108 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionMultimodalResponseImageWithGenerateContent" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.JsonSerializable; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ResponseModality; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.types.GenerateContentConfig; +import com.google.genai.types.GenerateContentResponse; + +/** + * An example of using the Unified Gen AI Java SDK to create an interaction with image response and + * generate content with image response. + */ +public final class InteractionMultimodalResponseImageWithGenerateContent { + public static void main(String[] args) throws Exception { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("[Interactions] Start interactions multimodal response image"); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .model("gemini-2.5-flash-image") + .responseModalities(ImmutableList.of(ResponseModality.IMAGE)) + .input(InteractionsInput.of("Generate an image of a futuristic cityscape at sunset.")) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + interaction.steps().ifPresent(steps -> { + int stepIndex = 1; + for (Step step : steps) { + System.out.println("Step " + stepIndex + ": " + step); + stepIndex++; + } + }); + + System.out.println("[Generate Content] Start generate content"); + GenerateContentConfig config = + GenerateContentConfig.builder().responseModalities(ImmutableList.of("TEXT", "IMAGE")).build(); + + GenerateContentResponse generateContentResponse = + client.models.generateContent( + "gemini-2.5-flash-image", + "Generate an image of a futuristic cityscape at sunset.", + config); + + System.out.println( + "Generate Content response: " + JsonSerializable.toJsonString(generateContentResponse)); + } + + private InteractionMultimodalResponseImageWithGenerateContent() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionStateful.java b/examples/src/main/java/com/google/genai/examples/InteractionStateful.java new file mode 100644 index 00000000000..a1ee3b3751c --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionStateful.java @@ -0,0 +1,113 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.InteractionStateful" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Unified Gen AI Java SDK to create a stateful interaction. */ +public final class InteractionStateful { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex AI"); + return; + } + + System.out.println("Using Gemini Developer API"); + + System.out.println("User: What are the three largest cities in Spain?"); + CreateModelInteraction params1 = + CreateModelInteraction.builder() + .input(InteractionsInput.of("What are the three largest cities in Spain?")) + .model(Constants.GEMINI_MODEL_NAME) + .build(); + + Interaction interaction1 = + client.interactions.create(CreateInteractionRequestBody.of(params1)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + System.out.println("Model: "); + printOutput(interaction1); + + System.out.println("\nUser: What is the most famous landmark in the second one?"); + CreateModelInteraction params2 = + CreateModelInteraction.builder() + .input(InteractionsInput.of("What is the most famous landmark in the second one?")) + .model(Constants.GEMINI_MODEL_NAME) + .previousInteractionId(interaction1.id().orElseThrow(() -> new RuntimeException("No ID returned"))) + .build(); + + Interaction interaction2 = + client.interactions.create(CreateInteractionRequestBody.of(params2)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + System.out.println("Model: "); + printOutput(interaction2); + } + + private static void printOutput(Interaction interaction) { + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println(text.text()); + } + } + }); + } + } + }); + } + + private InteractionStateful() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionStateless.java b/examples/src/main/java/com/google/genai/examples/InteractionStateless.java new file mode 100644 index 00000000000..deadfdec7fd --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionStateless.java @@ -0,0 +1,160 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.InteractionStateless" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.UserInputStep; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.util.ArrayList; +import java.util.List; + +/** + * An example of using the Unified Gen AI Java SDK to create a stateless interaction (multi-turn + * chat). + */ +public final class InteractionStateless { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } else { + System.out.println("Using Gemini Developer API"); + } + + List conversationHistory = new ArrayList<>(); + conversationHistory.add( + Step.of( + UserInputStep.builder() + .content( + List.of( + Content.of( + TextContent.builder() + .text("What are the three largest cities in Spain?") + .build()))) + .build())); + + System.out.println("User: What are the three largest cities in Spain?"); + + CreateModelInteraction params1 = + CreateModelInteraction.builder() + .input(InteractionsInput.ofStep(conversationHistory)) + .model(Constants.GEMINI_MODEL_NAME) + .store(false) + .build(); + + Interaction response1 = + client.interactions.create(CreateInteractionRequestBody.of(params1)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Model: "); + // Add model response to history + response1.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content output : contents) { + if (output.value() instanceof TextContent) { + TextContent text = (TextContent) output.value(); + System.out.println(text.text()); + } + } + }); + } + conversationHistory.add(step); + } + }); + + // Add next user message + conversationHistory.add( + Step.of( + UserInputStep.builder() + .content( + List.of( + Content.of( + TextContent.builder() + .text("What is the most famous landmark in the second one?") + .build()))) + .build())); + + System.out.println("\nUser: What is the most famous landmark in the second one?"); + + CreateModelInteraction params2 = + CreateModelInteraction.builder() + .input(InteractionsInput.ofStep(conversationHistory)) + .model(Constants.GEMINI_MODEL_NAME) + .store(false) + .build(); + + Interaction response2 = + client.interactions.create(CreateInteractionRequestBody.of(params2)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Model: "); + response2.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content output : contents) { + if (output.value() instanceof TextContent) { + TextContent text = (TextContent) output.value(); + System.out.println(text.text()); + } + } + }); + } + } + }); + } + + private InteractionStateless() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionStreaming.java b/examples/src/main/java/com/google/genai/examples/InteractionStreaming.java new file mode 100644 index 00000000000..c5ff3f843f7 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionStreaming.java @@ -0,0 +1,94 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.InteractionStreaming" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.InteractionSSEEvent; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.StepDelta; +import com.google.genai.gaos.models.interactions.StepDeltaData; +import com.google.genai.gaos.models.interactions.TextDelta; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.gaos.models.operations.CreateInteractionResponse; +import com.google.genai.gaos.utils.EventStream; + +/** An example of using the Unified Gen AI Java SDK to stream an interaction. */ +public final class InteractionStreaming { + public static void main(String[] args) throws Exception { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex AI"); + return; + } + + System.out.println("Using Gemini Developer API"); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("Tell me a story")) + .model(Constants.GEMINI_MODEL_NAME) + .stream(true) + .build(); + + CreateInteractionResponse response = + client.interactions.create(CreateInteractionRequestBody.of(params)); + + try (EventStream eventStream = response.events()) { + for (InteractionSSEStreamEvent streamEvent : eventStream) { + InteractionSSEEvent event = streamEvent.data(); + if (event.value() instanceof StepDelta) { + StepDelta stepDelta = (StepDelta) event.value(); + StepDeltaData data = stepDelta.delta(); + if (data.value() instanceof TextDelta) { + TextDelta textDelta = (TextDelta) data.value(); + System.out.print(textDelta.text()); + System.out.flush(); + } + } + } + System.out.println(); + } + } + + private InteractionStreaming() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionStructuredOutputJson.java b/examples/src/main/java/com/google/genai/examples/InteractionStructuredOutputJson.java new file mode 100644 index 00000000000..c7b225600a8 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionStructuredOutputJson.java @@ -0,0 +1,94 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionStructuredOutputJson" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.CreateModelInteractionResponseFormat; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ResponseFormat; +import com.google.genai.gaos.models.interactions.TextResponseFormat; +import com.google.genai.gaos.models.interactions.TextResponseFormatMimeType; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import java.util.HashMap; +import java.util.Map; + +/** Example of requesting structured JSON output using the Interactions API. */ +public class InteractionStructuredOutputJson { + + private static void createInteractions(Client client) { + + Map format = new HashMap<>(); + format.put("type", "array"); + format.put("description", "A list of colors"); + + TextResponseFormat textResponseFormat = TextResponseFormat.builder() + .mimeType(TextResponseFormatMimeType.APPLICATION_JSON) + .schema(format) + .build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .model(Constants.GEMINI_MODEL_NAME) + .input(InteractionsInput.of("Which are the colors of a rainbow")) + .responseFormat(CreateModelInteractionResponseFormat.of(ResponseFormat.of(textResponseFormat))) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println(interaction); + } + + public static void main(String[] args) throws Exception { + Client client = new Client(); + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + createInteractions(client); + } + + private InteractionStructuredOutputJson() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithCodeExecution.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithCodeExecution.java new file mode 100644 index 00000000000..8b24394000b --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithCodeExecution.java @@ -0,0 +1,104 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionToolCallWithCodeExecution" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.CodeExecution; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.Tool; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Interactions API with code execution tool. */ +public final class InteractionToolCallWithCodeExecution { + public static void main(String[] args) throws Exception { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("Using Gemini Developer API"); + + CodeExecution codeExecution = CodeExecution.builder().build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("What is the sum of the first 100 integers?")) + .model(Constants.GEMINI_MODEL_NAME) + .tools(ImmutableList.of(Tool.of(codeExecution))) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + // Print the text outputs from the interaction. + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionToolCallWithCodeExecution() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithComputerUse.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithComputerUse.java new file mode 100644 index 00000000000..3fa0a443686 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithComputerUse.java @@ -0,0 +1,115 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionToolCallWithComputerUse" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.ComputerUse; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.EnvironmentEnum; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.Tool; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** + * An example of using the Unified Gen AI Java SDK to create an interaction with computer use tool. + */ +public final class InteractionToolCallWithComputerUse { + public static void main(String[] args) throws Exception { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } else { + System.out.println("Using Gemini Developer API"); + } + + ComputerUse computerUse = + ComputerUse.builder() + .environment(EnvironmentEnum.BROWSER) + .build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .model("gemini-2.5-computer-use-preview-10-2025") + .input( + InteractionsInput.of( + "Search for highly rated smart fridges with touchscreen, 2 doors, around 25 cu ft," + + " priced below 4000 dollars on Google Shopping. Create a bulleted list of the" + + " 3 cheapest options in the format of name, description, price in an" + + " easy-to-read layout.")) + .tools(ImmutableList.of(Tool.of(computerUse))) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + // Print the text outputs from the interaction. + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionToolCallWithComputerUse() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithFunctions.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithFunctions.java new file mode 100644 index 00000000000..b9d8e42d83c --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithFunctions.java @@ -0,0 +1,151 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionToolCallWithFunctions" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Function; +import com.google.genai.gaos.models.interactions.FunctionCallStep; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.Tool; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Unified Gen AI Java SDK to perform tool calling with functions. */ +public final class InteractionToolCallWithFunctions { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex AI"); + return; + } + + System.out.println("Using Gemini Developer API"); + + ImmutableMap attendeesSchema = + ImmutableMap.of( + "type", + "array", + "items", + ImmutableMap.of("type", "string"), + "description", + "List of people attending the meeting."); + ImmutableMap dateSchema = + ImmutableMap.of("type", "string", "description", "Date of the meeting (e.g., 2024-07-29)"); + ImmutableMap timeSchema = + ImmutableMap.of("type", "string", "description", "Time of the meeting (e.g., 15:00)"); + ImmutableMap topicSchema = + ImmutableMap.of("type", "string", "description", "The subject or topic of the meeting."); + + ImmutableMap properties = + ImmutableMap.of( + "attendees", + attendeesSchema, + "date", + dateSchema, + "time", + timeSchema, + "topic", + topicSchema); + + ImmutableMap parametersSchema = + ImmutableMap.of( + "type", + "object", + "properties", + properties, + "required", + ImmutableList.of("attendees", "date", "time", "topic")); + + Function function = + Function.builder() + .name("schedule_meeting") + .description("Schedules a meeting with specified attendees at a given time and date.") + .parameters(parametersSchema) + .build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of( + "Schedule a meeting for 10/06/2028 at 10 am with Peter and Amir about the Next Gen" + + " API")) + .model(Constants.GEMINI_MODEL_NAME) + .tools(ImmutableList.of(Tool.of(function))) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof FunctionCallStep) { + FunctionCallStep fc = (FunctionCallStep) step.value(); + System.out.println("Function Call: " + fc.name()); + System.out.println("Arguments: " + fc.arguments()); + } else if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output Text: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionToolCallWithFunctions() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithGoogleSearch.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithGoogleSearch.java new file mode 100644 index 00000000000..7521e134b35 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithGoogleSearch.java @@ -0,0 +1,103 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionToolCallWithGoogleSearch" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.GoogleSearch; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.Tool; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Unified Gen AI Java SDK to perform tool calling with Google Search. */ +public final class InteractionToolCallWithGoogleSearch { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex AI"); + return; + } + + System.out.println("Using Gemini Developer API"); + + GoogleSearch googleSearch = GoogleSearch.builder().build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("Why is the sky blue")) + .model(Constants.GEMINI_MODEL_NAME) + .tools(ImmutableList.of(Tool.of(googleSearch))) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output Text: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionToolCallWithGoogleSearch() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithMcpServer.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithMcpServer.java new file mode 100644 index 00000000000..4f447dfd6d6 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithMcpServer.java @@ -0,0 +1,111 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionToolCallWithMcpServer" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.MCPServer; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.Tool; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Interactions API with an MCP server tool. */ +public final class InteractionToolCallWithMcpServer { + public static void main(String[] args) throws Exception { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("Using Gemini Developer API"); + + MCPServer mcpServer = + MCPServer.builder() + .name("weather_service") + .url("https://gemini-api-demos.uc.r.appspot.com/mcp") + .build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("What is the temperature today in London?")) + .systemInstruction( + "Today is 9-23-2025. Any dates before this are in the past, and any dates after" + + " this are in the future.") + .model(Constants.GEMINI_MODEL_NAME) + .tools(ImmutableList.of(Tool.of(mcpServer))) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + // Print the text outputs from the interaction. + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionToolCallWithMcpServer() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithUrlContext.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithUrlContext.java new file mode 100644 index 00000000000..387f27b74a7 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithUrlContext.java @@ -0,0 +1,108 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java + * -Dexec.mainClass="com.google.genai.examples.InteractionToolCallWithUrlContext" + */ +package com.google.genai.examples; + +import com.google.common.collect.ImmutableList; +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.interactions.Tool; +import com.google.genai.gaos.models.interactions.URLContext; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Interactions API with URL context tool. */ +public final class InteractionToolCallWithUrlContext { + public static void main(String[] args) throws Exception { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex"); + return; + } + + System.out.println("Using Gemini Developer API"); + + URLContext urlContext = URLContext.builder().build(); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input( + InteractionsInput.of( + "Compare the ingredients and cooking times from the recipes at" + + " https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592" + + " and https://www.allrecipes.com/recipe/21151/simple-whole-roast-chicken/")) + .model(Constants.GEMINI_MODEL_NAME) + .tools(ImmutableList.of(Tool.of(urlContext))) + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + // Print the text outputs from the interaction. + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionToolCallWithUrlContext() {} +} diff --git a/examples/src/main/java/com/google/genai/examples/InteractionWithConfig.java b/examples/src/main/java/com/google/genai/examples/InteractionWithConfig.java new file mode 100644 index 00000000000..db4cb7fe434 --- /dev/null +++ b/examples/src/main/java/com/google/genai/examples/InteractionWithConfig.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +/** + * Usage: + * + *

1a. If you are using Vertex AI, setup ADC to get credentials: + * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp + * + *

Then set Project, Location, and USE_VERTEXAI flag as environment variables: + * + *

export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT + * + *

export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION + * + *

export GOOGLE_GENAI_USE_VERTEXAI=true + * + *

1b. If you are using Gemini Developer API, set an API key environment variable. You can find a + * list of available API keys here: https://aistudio.google.com/app/apikey + * + *

export GOOGLE_API_KEY=YOUR_API_KEY + * + *

2. Compile the java package and run the sample code. + * + *

mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.InteractionWithConfig" + */ +package com.google.genai.examples; + +import com.google.genai.Client; +import com.google.genai.gaos.models.interactions.Content; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionsInput; +import com.google.genai.gaos.models.interactions.ModelOutputStep; +import com.google.genai.gaos.models.interactions.Step; +import com.google.genai.gaos.models.interactions.TextContent; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; + +/** An example of using the Unified Gen AI Java SDK to create an interaction with config. */ +public final class InteractionWithConfig { + public static void main(String[] args) { + Client client = new Client(); + + if (client.vertexAI()) { + System.out.println("Interactions API is not yet supported on Vertex AI"); + return; + } + + System.out.println("Using Gemini Developer API"); + + CreateModelInteraction params = + CreateModelInteraction.builder() + .input(InteractionsInput.of("Tell me a story")) + .model(Constants.GEMINI_MODEL_NAME) + .systemInstruction("You are a helpful assistant") + .build(); + + Interaction interaction = + client.interactions.create(CreateInteractionRequestBody.of(params)) + .interaction() + .orElseThrow(() -> new RuntimeException("Failed to create interaction")); + + System.out.println("Interaction ID: " + interaction.id().orElse("")); + System.out.println("Status: " + interaction.status()); + + interaction.steps().ifPresent(steps -> { + for (Step step : steps) { + if (step.value() instanceof ModelOutputStep) { + ModelOutputStep modelOutput = (ModelOutputStep) step.value(); + modelOutput.content().ifPresent(contents -> { + for (Content content : contents) { + if (content.value() instanceof TextContent) { + TextContent text = (TextContent) content.value(); + System.out.println("Output: " + text.text()); + } + } + }); + } + } + }); + } + + private InteractionWithConfig() {} +} diff --git a/pom.xml b/pom.xml index 90f687c09f1..4804b6ccc10 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,7 @@ 5.11.4 1.6.0 4.12.0 + 1.9.10 src/main/java src/test/java @@ -122,6 +123,11 @@ okhttp ${okhttp.version} + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + 1.9.10 + com.google.protobuf protobuf-java @@ -158,11 +164,6 @@ jspecify 1.0.0 - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - 1.9.10 - @@ -301,6 +302,18 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + + checkstyle + + **/gaos/**/*.java + + + + org.jacoco jacoco-maven-plugin @@ -391,52 +404,7 @@ - - org.apache.maven.plugins - maven-shade-plugin - 3.6.0 - - - package - - shade - - - - - org.jetbrains.kotlin:kotlin-stdlib-jdk8 - org.jetbrains.kotlin:kotlin-stdlib - org.jetbrains.kotlin:kotlin-reflect - com.fasterxml.jackson.module:jackson-module-kotlin - - - - - - - - kotlin. - com.google.genai.shaded.kotlin. - - - com.fasterxml.jackson.module.kotlin. - com.google.genai.shaded.jackson.module.kotlin. - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - + org.codehaus.mojo build-helper-maven-plugin @@ -456,9 +424,17 @@ + + org.codehaus.mojo + animal-sniffer-maven-plugin + + true + + + jdk8-build diff --git a/src/main/java/com/google/genai/ApiClient.java b/src/main/java/com/google/genai/ApiClient.java index 3119b6b2f9c..5696d859b3d 100644 --- a/src/main/java/com/google/genai/ApiClient.java +++ b/src/main/java/com/google/genai/ApiClient.java @@ -77,6 +77,7 @@ public abstract class ApiClient implements AutoCloseable { HttpOptions httpOptions; final boolean vertexAI; final Optional clientOptions; + final Optional customBaseUrl; // For Google AI APIs final Optional apiKey; @@ -120,6 +121,7 @@ protected ApiClient( } this.httpClient = createHttpClient(httpOptions, clientOptions); + } ApiClient( @@ -274,6 +276,7 @@ protected ApiClient( } this.vertexAI = true; this.httpClient = createHttpClient(httpOptions, clientOptions); + } private OkHttpClient createHttpClient( @@ -371,6 +374,8 @@ private void applyProxyOptions(ProxyOptions proxyOptions, OkHttpClient.Builder b } } + + /** Builds a HTTP request given the http method, path, and request json string. */ @SuppressWarnings("unchecked") protected Request buildRequest( @@ -910,6 +915,7 @@ public void close() { if (httpClient().cache() != null) { httpClient().cache().close(); } + } catch (IOException e) { throw new GenAiIOException("Failed to close the client.", e); } diff --git a/src/main/java/com/google/genai/Client.java b/src/main/java/com/google/genai/Client.java index 763d04507f8..017bd36bfdd 100644 --- a/src/main/java/com/google/genai/Client.java +++ b/src/main/java/com/google/genai/Client.java @@ -21,6 +21,13 @@ import com.google.auth.oauth2.GoogleCredentials; import com.google.common.collect.ImmutableMap; import com.google.errorprone.annotations.CanIgnoreReturnValue; +// android:strip_begin +import com.google.genai.gaos.GenAI; +import com.google.genai.gaos.AsyncGenAI; +import com.google.genai.gaos.SecuritySource; +import com.google.genai.gaos.utils.HasSecurity; +import java.io.IOException; +// android:strip_end import com.google.genai.types.ClientOptions; import com.google.genai.types.HttpOptions; import java.util.Optional; @@ -43,6 +50,11 @@ public final class Async { public final AsyncTokens authTokens; public final AsyncTunings tunings; public final AsyncFileSearchStores fileSearchStores; + // android:strip_begin + public final com.google.genai.gaos.AsyncInteractions interactions; + public final com.google.genai.gaos.AsyncAgents agents; + public final com.google.genai.gaos.AsyncWebhooks webhooks; + // android:strip_end public Async(ApiClient apiClient) { this.models = new AsyncModels(apiClient); @@ -55,6 +67,12 @@ public Async(ApiClient apiClient) { this.authTokens = new AsyncTokens(apiClient); this.tunings = new AsyncTunings(apiClient); this.fileSearchStores = new AsyncFileSearchStores(apiClient); + // android:strip_begin + AsyncGenAI asyncGaos = Client.this.gaosClient.async(); + this.interactions = asyncGaos.interactions(); + this.agents = asyncGaos.agents(); + this.webhooks = asyncGaos.webhooks(); + // android:strip_end } } @@ -70,6 +88,12 @@ public Async(ApiClient apiClient) { public final Tokens authTokens; public final Tunings tunings; public final FileSearchStores fileSearchStores; + // android:strip_begin + private final GenAI gaosClient; + public final com.google.genai.gaos.Interactions interactions; + public final com.google.genai.gaos.Agents agents; + public final com.google.genai.gaos.Webhooks webhooks; + // android:strip_end /** Builder for {@link Client}. */ public static class Builder { @@ -315,11 +339,62 @@ private Client( caches = new Caches(apiClient); operations = new Operations(this.apiClient); chats = new Chats(this.apiClient); + + // android:strip_begin + GenAI.Builder gaosBuilder = GenAI.builder(); + this.apiClient.httpOptions().baseUrl().ifPresent(gaosBuilder::serverURL); + this.apiClient.httpOptions().apiVersion().ifPresent(gaosBuilder::apiVersion); + gaosBuilder.apiRevision("2026-05-20"); + if (apiClient.credentials() != null && apiClient.credentials().getQuotaProjectId() != null) { + gaosBuilder.userProject(apiClient.credentials().getQuotaProjectId()); + } + gaosBuilder.securitySource(new SecuritySource() { + @Override + public HasSecurity getSecurity() { + com.google.genai.gaos.models.shared.Security.Builder builder = com.google.genai.gaos.models.shared.Security.builder(); + if (apiClient.apiKey() != null) { + builder.apiKey(apiClient.apiKey()); + } else if (apiClient.credentials() != null) { + GoogleCredentials creds = apiClient.credentials(); + try { + creds.refreshIfExpired(); + } catch (IOException e) { + throw new RuntimeException("Failed to refresh credentials for GAOS client", e); + } + builder.accessToken(creds.getAccessToken().getTokenValue()); + } + java.util.Map headersMap = new java.util.HashMap<>(); + apiClient.httpOptions().headers().ifPresent(headersMap::putAll); + // DO_NOT_SUBMIT + headersMap.put("Api-Revision", "2026-05-20"); + String ua = headersMap.get("user-agent"); + if (ua != null) { + headersMap.put("user-agent", ua.replaceAll("google-genai-sdk/1\\.[0-9]+\\.[0-9]+", "google-genai-sdk/2.0.0")); + } else { + headersMap.put("user-agent", "google-genai-sdk/2.0.0 gl-java/" + System.getProperty("java.version")); + } + String xgac = headersMap.get("x-goog-api-client"); + if (xgac != null) { + headersMap.put("x-goog-api-client", xgac.replaceAll("google-genai-sdk/1\\.[0-9]+\\.[0-9]+", "google-genai-sdk/2.0.0")); + } else { + headersMap.put("x-goog-api-client", "google-genai-sdk/2.0.0 gl-java/" + System.getProperty("java.version")); + } + builder.defaultHeaders(headersMap); + return builder.build(); + } + }); + this.gaosClient = gaosBuilder.build(); + this.interactions = gaosClient.interactions(); + this.agents = gaosClient.agents(); + this.webhooks = gaosClient.webhooks(); + // android:strip_end + async = new Async(this.apiClient); files = new Files(this.apiClient); authTokens = new Tokens(this.apiClient); tunings = new Tunings(this.apiClient); fileSearchStores = new FileSearchStores(this.apiClient); + } /** Returns whether the client is using Vertex AI APIs. */ diff --git a/src/main/java/com/google/genai/gaos/Agents.java b/src/main/java/com/google/genai/gaos/Agents.java new file mode 100644 index 00000000000..318c45ffc8e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/Agents.java @@ -0,0 +1,263 @@ +/* +* 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; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.models.operations.CreateAgentRequest; +import com.google.genai.gaos.models.operations.CreateAgentRequestBuilder; +import com.google.genai.gaos.models.operations.CreateAgentResponse; +import com.google.genai.gaos.models.operations.DeleteAgentRequest; +import com.google.genai.gaos.models.operations.DeleteAgentRequestBuilder; +import com.google.genai.gaos.models.operations.DeleteAgentResponse; +import com.google.genai.gaos.models.operations.GetAgentRequest; +import com.google.genai.gaos.models.operations.GetAgentRequestBuilder; +import com.google.genai.gaos.models.operations.GetAgentResponse; +import com.google.genai.gaos.models.operations.ListAgentsRequest; +import com.google.genai.gaos.models.operations.ListAgentsRequestBuilder; +import com.google.genai.gaos.models.operations.ListAgentsResponse; +import com.google.genai.gaos.operations.CreateAgent; +import com.google.genai.gaos.operations.DeleteAgent; +import com.google.genai.gaos.operations.GetAgent; +import com.google.genai.gaos.operations.ListAgents; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import java.lang.Integer; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class Agents { + private static final Headers _headers = Headers.EMPTY; + private final SDKConfiguration sdkConfiguration; + private final AsyncAgents asyncSDK; + + Agents(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.asyncSDK = new AsyncAgents(this, sdkConfiguration); + } + + /** + * Switches to the async SDK. + * + * @return The async SDK + */ + public AsyncAgents async() { + return asyncSDK; + } + + /** + * Creates a new Agent (Typed version for SDK). + * + * @return The call builder + */ + public CreateAgentRequestBuilder create() { + return new CreateAgentRequestBuilder(sdkConfiguration); + } + + /** + * Creates a new Agent (Typed version for SDK). + * + * @param body An agent definition for the CreateAgent API. + * This message is the target for annotation-parser-based JSON parsing. + * New format: + * { + * "id": "customer-sentinel", + * "base_agent": "", + * "system_instruction": "...", + * "base_environment": { "type": "remote", "sources": [...] }, + * "tools": [ {"type": "code_execution"} ] + * } + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public CreateAgentResponse create(Agent body) { + return create(Optional.empty(), body, Optional.empty()); + } + + /** + * Creates a new Agent (Typed version for SDK). + * + * @param apiVersion Which version of the API to use. + * @param body An agent definition for the CreateAgent API. + * This message is the target for annotation-parser-based JSON parsing. + * New format: + * { + * "id": "customer-sentinel", + * "base_agent": "", + * "system_instruction": "...", + * "base_environment": { "type": "remote", "sources": [...] }, + * "tools": [ {"type": "code_execution"} ] + * } + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public CreateAgentResponse create( + Optional apiVersion, Agent body, + Optional options) { + CreateAgentRequest request = + CreateAgentRequest + .builder() + .apiVersion(apiVersion) + .body(body) + .build(); + RequestOperation operation + = new CreateAgent.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Lists all Agents. + * + * @return The call builder + */ + public ListAgentsRequestBuilder list() { + return new ListAgentsRequestBuilder(sdkConfiguration); + } + + /** + * Lists all Agents. + * + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public ListAgentsResponse listDirect() { + return list(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + /** + * Lists all Agents. + * + * @param apiVersion Which version of the API to use. + * @param pageSize + * @param pageToken + * @param parent + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public ListAgentsResponse list( + Optional apiVersion, Optional pageSize, + Optional pageToken, Optional parent, + Optional options) { + ListAgentsRequest request = + ListAgentsRequest + .builder() + .apiVersion(apiVersion) + .pageSize(pageSize) + .pageToken(pageToken) + .parent(parent) + .build(); + RequestOperation operation + = new ListAgents.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Gets a specific Agent. + * + * @return The call builder + */ + public GetAgentRequestBuilder get() { + return new GetAgentRequestBuilder(sdkConfiguration); + } + + /** + * Gets a specific Agent. + * + * @param id + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public GetAgentResponse get(String id) { + return get(Optional.empty(), id, Optional.empty()); + } + + /** + * Gets a specific Agent. + * + * @param apiVersion Which version of the API to use. + * @param id + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public GetAgentResponse get( + Optional apiVersion, String id, + Optional options) { + GetAgentRequest request = + GetAgentRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .build(); + RequestOperation operation + = new GetAgent.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Deletes an Agent. + * + * @return The call builder + */ + public DeleteAgentRequestBuilder delete() { + return new DeleteAgentRequestBuilder(sdkConfiguration); + } + + /** + * Deletes an Agent. + * + * @param id + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public DeleteAgentResponse delete(String id) { + return delete(Optional.empty(), id, Optional.empty()); + } + + /** + * Deletes an Agent. + * + * @param apiVersion Which version of the API to use. + * @param id + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public DeleteAgentResponse delete( + Optional apiVersion, String id, + Optional options) { + DeleteAgentRequest request = + DeleteAgentRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .build(); + RequestOperation operation + = new DeleteAgent.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + +} diff --git a/src/main/java/com/google/genai/gaos/AsyncAgents.java b/src/main/java/com/google/genai/gaos/AsyncAgents.java new file mode 100644 index 00000000000..ac0597f42b8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/AsyncAgents.java @@ -0,0 +1,273 @@ +/* +* 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; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.models.operations.CreateAgentRequest; +import com.google.genai.gaos.models.operations.DeleteAgentRequest; +import com.google.genai.gaos.models.operations.GetAgentRequest; +import com.google.genai.gaos.models.operations.ListAgentsRequest; +import com.google.genai.gaos.models.operations.async.CreateAgentRequestBuilder; +import com.google.genai.gaos.models.operations.async.CreateAgentResponse; +import com.google.genai.gaos.models.operations.async.DeleteAgentRequestBuilder; +import com.google.genai.gaos.models.operations.async.DeleteAgentResponse; +import com.google.genai.gaos.models.operations.async.GetAgentRequestBuilder; +import com.google.genai.gaos.models.operations.async.GetAgentResponse; +import com.google.genai.gaos.models.operations.async.ListAgentsRequestBuilder; +import com.google.genai.gaos.models.operations.async.ListAgentsResponse; +import com.google.genai.gaos.operations.CreateAgent; +import com.google.genai.gaos.operations.DeleteAgent; +import com.google.genai.gaos.operations.GetAgent; +import com.google.genai.gaos.operations.ListAgents; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import java.lang.Integer; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + + +@SuppressWarnings("all") +public class AsyncAgents { + private static final Headers _headers = Headers.EMPTY; + private final SDKConfiguration sdkConfiguration; + private final Agents syncSDK; + + AsyncAgents(Agents syncSDK, SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.syncSDK = syncSDK; + } + + /** + * Switches to the sync SDK. + * + * @return The sync SDK + */ + public Agents sync() { + return syncSDK; + } + + + /** + * Creates a new Agent (Typed version for SDK). + * + * @return The async call builder + */ + public CreateAgentRequestBuilder create() { + return new CreateAgentRequestBuilder(sdkConfiguration); + } + + /** + * Creates a new Agent (Typed version for SDK). + * + * @param body An agent definition for the CreateAgent API. + * This message is the target for annotation-parser-based JSON parsing. + * New format: + * { + * "id": "customer-sentinel", + * "base_agent": "", + * "system_instruction": "...", + * "base_environment": { "type": "remote", "sources": [...] }, + * "tools": [ {"type": "code_execution"} ] + * } + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture create(Agent body) { + return create(Optional.empty(), body, Optional.empty()); + } + + /** + * Creates a new Agent (Typed version for SDK). + * + * @param apiVersion Which version of the API to use. + * @param body An agent definition for the CreateAgent API. + * This message is the target for annotation-parser-based JSON parsing. + * New format: + * { + * "id": "customer-sentinel", + * "base_agent": "", + * "system_instruction": "...", + * "base_environment": { "type": "remote", "sources": [...] }, + * "tools": [ {"type": "code_execution"} ] + * } + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture create( + Optional apiVersion, Agent body, + Optional options) { + CreateAgentRequest request = + CreateAgentRequest + .builder() + .apiVersion(apiVersion) + .body(body) + .build(); + AsyncRequestOperation operation + = new CreateAgent.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Lists all Agents. + * + * @return The async call builder + */ + public ListAgentsRequestBuilder list() { + return new ListAgentsRequestBuilder(sdkConfiguration); + } + + /** + * Lists all Agents. + * + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture listDirect() { + return list( + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + /** + * Lists all Agents. + * + * @param apiVersion Which version of the API to use. + * @param pageSize + * @param pageToken + * @param parent + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture list( + Optional apiVersion, Optional pageSize, + Optional pageToken, Optional parent, + Optional options) { + ListAgentsRequest request = + ListAgentsRequest + .builder() + .apiVersion(apiVersion) + .pageSize(pageSize) + .pageToken(pageToken) + .parent(parent) + .build(); + AsyncRequestOperation operation + = new ListAgents.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Gets a specific Agent. + * + * @return The async call builder + */ + public GetAgentRequestBuilder get() { + return new GetAgentRequestBuilder(sdkConfiguration); + } + + /** + * Gets a specific Agent. + * + * @param id + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture get(String id) { + return get(Optional.empty(), id, Optional.empty()); + } + + /** + * Gets a specific Agent. + * + * @param apiVersion Which version of the API to use. + * @param id + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture get( + Optional apiVersion, String id, + Optional options) { + GetAgentRequest request = + GetAgentRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .build(); + AsyncRequestOperation operation + = new GetAgent.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Deletes an Agent. + * + * @return The async call builder + */ + public DeleteAgentRequestBuilder delete() { + return new DeleteAgentRequestBuilder(sdkConfiguration); + } + + /** + * Deletes an Agent. + * + * @param id + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture delete(String id) { + return delete(Optional.empty(), id, Optional.empty()); + } + + /** + * Deletes an Agent. + * + * @param apiVersion Which version of the API to use. + * @param id + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture delete( + Optional apiVersion, String id, + Optional options) { + DeleteAgentRequest request = + DeleteAgentRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .build(); + AsyncRequestOperation operation + = new DeleteAgent.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + +} diff --git a/src/main/java/com/google/genai/gaos/AsyncGenAI.java b/src/main/java/com/google/genai/gaos/AsyncGenAI.java new file mode 100644 index 00000000000..bd42db30561 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/AsyncGenAI.java @@ -0,0 +1,74 @@ +/* +* 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; + +import com.google.genai.gaos.utils.Headers; + +/** + * Gemini API: The Gemini Interactions API allows developers to build generative AI applications using + * Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. It can + * generalize and seamlessly understand, operate across, and combine different types of information + * including language, images, audio, video, and code. + * + *

You can use the Gemini API for use cases like reasoning across text and images, content generation, + * dialogue agents, summarization and classification systems, and more. + */ +@SuppressWarnings("all") +public class AsyncGenAI { + private static final Headers _headers = Headers.EMPTY; + + private final AsyncInteractions interactions; + + private final AsyncWebhooks webhooks; + + private final AsyncAgents agents; + + public AsyncInteractions interactions() { + return interactions; + } + + public AsyncWebhooks webhooks() { + return webhooks; + } + + public AsyncAgents agents() { + return agents; + } + + private final SDKConfiguration sdkConfiguration; + private final GenAI syncSDK; + + AsyncGenAI(GenAI syncSDK, SDKConfiguration sdkConfiguration) { + this.syncSDK = syncSDK; + this.sdkConfiguration = sdkConfiguration; + this.interactions = new AsyncInteractions(syncSDK.interactions(), sdkConfiguration); + this.webhooks = new AsyncWebhooks(syncSDK.webhooks(), sdkConfiguration); + this.agents = new AsyncAgents(syncSDK.agents(), sdkConfiguration); + } + + /** + * Switches to the sync SDK. + * + * @return The sync SDK + */ + public GenAI sync() { + return syncSDK; + } +} diff --git a/src/main/java/com/google/genai/gaos/AsyncInteractions.java b/src/main/java/com/google/genai/gaos/AsyncInteractions.java new file mode 100644 index 00000000000..7209bded0e3 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/AsyncInteractions.java @@ -0,0 +1,277 @@ +/* +* 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; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.models.operations.CancelInteractionByIdRequest; +import com.google.genai.gaos.models.operations.CreateInteractionRequest; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.gaos.models.operations.DeleteInteractionRequest; +import com.google.genai.gaos.models.operations.GetInteractionByIdRequest; +import com.google.genai.gaos.models.operations.async.CancelInteractionByIdRequestBuilder; +import com.google.genai.gaos.models.operations.async.CancelInteractionByIdResponse; +import com.google.genai.gaos.models.operations.async.CreateInteractionRequestBuilder; +import com.google.genai.gaos.models.operations.async.CreateInteractionResponse; +import com.google.genai.gaos.models.operations.async.DeleteInteractionRequestBuilder; +import com.google.genai.gaos.models.operations.async.DeleteInteractionResponse; +import com.google.genai.gaos.models.operations.async.GetInteractionByIdRequestBuilder; +import com.google.genai.gaos.models.operations.async.GetInteractionByIdResponse; +import com.google.genai.gaos.operations.CancelInteractionById; +import com.google.genai.gaos.operations.CreateInteraction; +import com.google.genai.gaos.operations.DeleteInteraction; +import com.google.genai.gaos.operations.GetInteractionById; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Utils; +import com.google.genai.gaos.utils.reactive.EventStream; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + + +@SuppressWarnings("all") +public class AsyncInteractions { + private static final Headers _headers = Headers.EMPTY; + private final SDKConfiguration sdkConfiguration; + private final Interactions syncSDK; + + AsyncInteractions(Interactions syncSDK, SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.syncSDK = syncSDK; + } + + /** + * Switches to the sync SDK. + * + * @return The sync SDK + */ + public Interactions sync() { + return syncSDK; + } + + + /** + * Creating an interaction + * + *

Creates a new interaction. + * + * @return The async call builder + */ + public CreateInteractionRequestBuilder create() { + return new CreateInteractionRequestBuilder(sdkConfiguration); + } + + /** + * Creating an interaction + * + *

Creates a new interaction. + * + * @param body The request body. + * @return {@code EventStream} - The async response + */ + public EventStream create(CreateInteractionRequestBody body) { + return create(Optional.empty(), body, Optional.empty()); + } + + /** + * Creating an interaction + * + *

Creates a new interaction. + * + * @param apiVersion Which version of the API to use. + * @param body The request body. + * @param options additional options + * @return A reactive SSE publisher that emits events from the server. + * Can be consumed using reactive streams toolkits such as RxJava, Project Reactor, or Java 9+ Flow API. + */ + public EventStream create( + Optional apiVersion, CreateInteractionRequestBody body, + Optional options) { + CreateInteractionRequest request = + CreateInteractionRequest + .builder() + .apiVersion(apiVersion) + .body(body) + .build(); + AsyncRequestOperation operation + = new CreateInteraction.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return EventStream.forSSE( + operation.doRequest(request).thenCompose(operation::handleResponse), + new TypeReference<>() { + }, + Utils.mapper(), + "[DONE]"); + } + + + /** + * Retrieving an interaction + * + *

Retrieves the full details of a single interaction based on its `Interaction.id`. + * + * @return The async call builder + */ + public GetInteractionByIdRequestBuilder get() { + return new GetInteractionByIdRequestBuilder(sdkConfiguration); + } + + /** + * Retrieving an interaction + * + *

Retrieves the full details of a single interaction based on its `Interaction.id`. + * + * @param request The request object containing all the parameters for the API call. + * @return {@code EventStream} - The async response + */ + public EventStream get(GetInteractionByIdRequest request) { + return get(request, Optional.empty()); + } + + /** + * Retrieving an interaction + * + *

Retrieves the full details of a single interaction based on its `Interaction.id`. + * + * @param request The request object containing all the parameters for the API call. + * @param options additional options + * @return A reactive SSE publisher that emits events from the server. + * Can be consumed using reactive streams toolkits such as RxJava, Project Reactor, or Java 9+ Flow API. + */ + public EventStream get(GetInteractionByIdRequest request, Optional options) { + AsyncRequestOperation operation + = new GetInteractionById.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return EventStream.forSSE( + operation.doRequest(request).thenCompose(operation::handleResponse), + new TypeReference<>() { + }, + Utils.mapper(), + "[DONE]"); + } + + + /** + * Deleting an interaction + * + *

Deletes the interaction by id. + * + * @return The async call builder + */ + public DeleteInteractionRequestBuilder delete() { + return new DeleteInteractionRequestBuilder(sdkConfiguration); + } + + /** + * Deleting an interaction + * + *

Deletes the interaction by id. + * + * @param id The unique identifier of the interaction to delete. + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture delete(String id) { + return delete(id, Optional.empty(), Optional.empty()); + } + + /** + * Deleting an interaction + * + *

Deletes the interaction by id. + * + * @param id The unique identifier of the interaction to delete. + * @param apiVersion Which version of the API to use. + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture delete( + String id, Optional apiVersion, + Optional options) { + DeleteInteractionRequest request = + DeleteInteractionRequest + .builder() + .id(id) + .apiVersion(apiVersion) + .build(); + AsyncRequestOperation operation + = new DeleteInteraction.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Canceling an interaction + * + *

Cancels an interaction by id. This only applies to background interactions that are still running. + * + * @return The async call builder + */ + public CancelInteractionByIdRequestBuilder cancel() { + return new CancelInteractionByIdRequestBuilder(sdkConfiguration); + } + + /** + * Canceling an interaction + * + *

Cancels an interaction by id. This only applies to background interactions that are still running. + * + * @param id The unique identifier of the interaction to cancel. + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture cancel(String id) { + return cancel(id, Optional.empty(), Optional.empty()); + } + + /** + * Canceling an interaction + * + *

Cancels an interaction by id. This only applies to background interactions that are still running. + * + * @param id The unique identifier of the interaction to cancel. + * @param apiVersion Which version of the API to use. + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture cancel( + String id, Optional apiVersion, + Optional options) { + CancelInteractionByIdRequest request = + CancelInteractionByIdRequest + .builder() + .id(id) + .apiVersion(apiVersion) + .build(); + AsyncRequestOperation operation + = new CancelInteractionById.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + +} diff --git a/src/main/java/com/google/genai/gaos/AsyncWebhooks.java b/src/main/java/com/google/genai/gaos/AsyncWebhooks.java new file mode 100644 index 00000000000..e969a130e36 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/AsyncWebhooks.java @@ -0,0 +1,424 @@ +/* +* 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; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.models.operations.CreateWebhookRequest; +import com.google.genai.gaos.models.operations.DeleteWebhookRequest; +import com.google.genai.gaos.models.operations.GetWebhookRequest; +import com.google.genai.gaos.models.operations.ListWebhooksRequest; +import com.google.genai.gaos.models.operations.UpdateWebhookRequest; +import com.google.genai.gaos.models.operations.async.CreateWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.async.CreateWebhookResponse; +import com.google.genai.gaos.models.operations.async.DeleteWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.async.DeleteWebhookResponse; +import com.google.genai.gaos.models.operations.async.GetWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.async.GetWebhookResponse; +import com.google.genai.gaos.models.operations.async.ListWebhooksRequestBuilder; +import com.google.genai.gaos.models.operations.async.ListWebhooksResponse; +import com.google.genai.gaos.models.operations.async.PingWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.async.PingWebhookResponse; +import com.google.genai.gaos.models.operations.async.RotateSigningSecretRequestBuilder; +import com.google.genai.gaos.models.operations.async.RotateSigningSecretResponse; +import com.google.genai.gaos.models.operations.async.UpdateWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.async.UpdateWebhookResponse; +import com.google.genai.gaos.models.webhooks.PingWebhookRequest; +import com.google.genai.gaos.models.webhooks.RotateSigningSecretRequest; +import com.google.genai.gaos.models.webhooks.WebhookInput; +import com.google.genai.gaos.models.webhooks.WebhookUpdate; +import com.google.genai.gaos.operations.CreateWebhook; +import com.google.genai.gaos.operations.DeleteWebhook; +import com.google.genai.gaos.operations.GetWebhook; +import com.google.genai.gaos.operations.ListWebhooks; +import com.google.genai.gaos.operations.PingWebhook; +import com.google.genai.gaos.operations.RotateSigningSecret; +import com.google.genai.gaos.operations.UpdateWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import java.lang.Integer; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + + +@SuppressWarnings("all") +public class AsyncWebhooks { + private static final Headers _headers = Headers.EMPTY; + private final SDKConfiguration sdkConfiguration; + private final Webhooks syncSDK; + + AsyncWebhooks(Webhooks syncSDK, SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.syncSDK = syncSDK; + } + + /** + * Switches to the sync SDK. + * + * @return The sync SDK + */ + public Webhooks sync() { + return syncSDK; + } + + + /** + * Creates a new Webhook. + * + * @return The async call builder + */ + public CreateWebhookRequestBuilder create() { + return new CreateWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Creates a new Webhook. + * + * @param body A Webhook resource. + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture create(WebhookInput body) { + return create(Optional.empty(), body, Optional.empty()); + } + + /** + * Creates a new Webhook. + * + * @param apiVersion Which version of the API to use. + * @param body A Webhook resource. + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture create( + Optional apiVersion, WebhookInput body, + Optional options) { + CreateWebhookRequest request = + CreateWebhookRequest + .builder() + .apiVersion(apiVersion) + .body(body) + .build(); + AsyncRequestOperation operation + = new CreateWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Lists all Webhooks. + * + * @return The async call builder + */ + public ListWebhooksRequestBuilder list() { + return new ListWebhooksRequestBuilder(sdkConfiguration); + } + + /** + * Lists all Webhooks. + * + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture listDirect() { + return list( + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + /** + * Lists all Webhooks. + * + * @param apiVersion Which version of the API to use. + * @param pageSize Optional. The maximum number of webhooks to return. The service may return fewer than + * this value. If unspecified, at most 50 webhooks will be returned. + * The maximum value is 1000. + * @param pageToken Optional. A page token, received from a previous `ListWebhooks` call. + * Provide this to retrieve the subsequent page. + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture list( + Optional apiVersion, Optional pageSize, + Optional pageToken, Optional options) { + ListWebhooksRequest request = + ListWebhooksRequest + .builder() + .apiVersion(apiVersion) + .pageSize(pageSize) + .pageToken(pageToken) + .build(); + AsyncRequestOperation operation + = new ListWebhooks.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Gets a specific Webhook. + * + * @return The async call builder + */ + public GetWebhookRequestBuilder get() { + return new GetWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Gets a specific Webhook. + * + * @param id Required. The ID of the webhook to retrieve. + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture get(String id) { + return get(Optional.empty(), id, Optional.empty()); + } + + /** + * Gets a specific Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook to retrieve. + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture get( + Optional apiVersion, String id, + Optional options) { + GetWebhookRequest request = + GetWebhookRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .build(); + AsyncRequestOperation operation + = new GetWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Updates an existing Webhook. + * + * @return The async call builder + */ + public UpdateWebhookRequestBuilder update() { + return new UpdateWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Updates an existing Webhook. + * + * @param id Required. The ID of the webhook to update. + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture update(String id) { + return update( + Optional.empty(), id, Optional.empty(), + Optional.empty(), Optional.empty()); + } + + /** + * Updates an existing Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook to update. + * @param updateMask Optional. The list of fields to update. + * @param body + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture update( + Optional apiVersion, String id, + Optional updateMask, Optional body, + Optional options) { + UpdateWebhookRequest request = + UpdateWebhookRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .updateMask(updateMask) + .body(body) + .build(); + AsyncRequestOperation operation + = new UpdateWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Deletes a Webhook. + * + * @return The async call builder + */ + public DeleteWebhookRequestBuilder delete() { + return new DeleteWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Deletes a Webhook. + * + * @param id Required. The ID of the webhook to delete. + * Format: `{webhook_id}` + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture delete(String id) { + return delete(Optional.empty(), id, Optional.empty()); + } + + /** + * Deletes a Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook to delete. + * Format: `{webhook_id}` + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture delete( + Optional apiVersion, String id, + Optional options) { + DeleteWebhookRequest request = + DeleteWebhookRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .build(); + AsyncRequestOperation operation + = new DeleteWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Generates a new signing secret for a Webhook. + * + * @return The async call builder + */ + public RotateSigningSecretRequestBuilder rotateSigningSecret() { + return new RotateSigningSecretRequestBuilder(sdkConfiguration); + } + + /** + * Generates a new signing secret for a Webhook. + * + * @param id Required. The ID of the webhook for which to generate a signing secret. + * Format: `{webhook_id}` + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture rotateSigningSecret(String id) { + return rotateSigningSecret( + Optional.empty(), id, Optional.empty(), + Optional.empty()); + } + + /** + * Generates a new signing secret for a Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook for which to generate a signing secret. + * Format: `{webhook_id}` + * @param body Request message for WebhookService.RotateSigningSecret. + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture rotateSigningSecret( + Optional apiVersion, String id, + Optional body, Optional options) { + com.google.genai.gaos.models.operations.RotateSigningSecretRequest request = + com.google.genai.gaos.models.operations.RotateSigningSecretRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .body(body) + .build(); + AsyncRequestOperation operation + = new RotateSigningSecret.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + + + /** + * Sends a ping event to a Webhook. + * + * @return The async call builder + */ + public PingWebhookRequestBuilder ping() { + return new PingWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Sends a ping event to a Webhook. + * + * @param id Required. The ID of the webhook to ping. + * Format: `{webhook_id}` + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture ping(String id) { + return ping( + Optional.empty(), id, Optional.empty(), + Optional.empty()); + } + + /** + * Sends a ping event to a Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook to ping. + * Format: `{webhook_id}` + * @param body Request message for WebhookService.PingWebhook. + * @param options additional options + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture ping( + Optional apiVersion, String id, + Optional body, Optional options) { + com.google.genai.gaos.models.operations.PingWebhookRequest request = + com.google.genai.gaos.models.operations.PingWebhookRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .body(body) + .build(); + AsyncRequestOperation operation + = new PingWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + +} diff --git a/src/main/java/com/google/genai/gaos/GenAI.java b/src/main/java/com/google/genai/gaos/GenAI.java new file mode 100644 index 00000000000..459e14b2e87 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/GenAI.java @@ -0,0 +1,284 @@ +/* +* 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; + +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.SdkInitData; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.SpeakeasyHTTPClient; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Map; +import java.util.Optional; +import java.util.function.Consumer; + +/** + * Gemini API: The Gemini Interactions API allows developers to build generative AI applications using + * Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. + * + *

It can generalize and seamlessly understand, operate across, and combine different types of + * information including language, images, audio, video, and code. You can use the Gemini API for use + * cases like reasoning across text and images, content generation, dialogue agents, summarization and + * classification systems, and more. + */ +@SuppressWarnings("all") +public class GenAI { + private static final Headers _headers = Headers.EMPTY; + + + /** + * SERVERS contains the list of server urls available to the SDK. + */ + public static final String[] SERVERS = { + /* + * Global Endpoint + */ + "https://generativelanguage.googleapis.com", + }; + + + private final Interactions interactions; + + + private final Webhooks webhooks; + + + private final Agents agents; + + + public Interactions interactions() { + return interactions; + } + + + public Webhooks webhooks() { + return webhooks; + } + + + public Agents agents() { + return agents; + } + private final AsyncGenAI asyncSDK; + + /** + * The Builder class allows the configuration of a new instance of the SDK. + */ + public static class Builder { + + private final SDKConfiguration sdkConfiguration = new SDKConfiguration(); + private String serverUrl; + private String server; + + + private Builder() { + } + + /** + * Allows the default HTTP client to be overridden with a custom implementation. + * + * @param client The HTTP client to use for all requests. + * @return The builder instance. + */ + public Builder client(HTTPClient client) { + this.sdkConfiguration.setClient(client); + return this; + } + + /** + * Configures the SDK to use the provided security details. + * + * @param security The security details to use for all requests. Can be {@code null}. + * @return The builder instance. + */ + public Builder security(com.google.genai.gaos.models.shared.Security security) { + this.sdkConfiguration.setSecuritySource(SecuritySource.of(security)); + return this; + } + + /** + * Configures the SDK to use a custom security source. + * + * @param securitySource The security source to use for all requests. + * @return The builder instance. + */ + public Builder securitySource(SecuritySource securitySource) { + Utils.checkNotNull(securitySource, "securitySource"); + this.sdkConfiguration.setSecuritySource(securitySource); + return this; + } + + /** + * Overrides the default server URL. + * + * @param serverUrl The server URL to use for all requests. + * @return The builder instance. + */ + public Builder serverURL(String serverUrl) { + this.serverUrl = serverUrl; + return this; + } + + /** + * Overrides the default server URL with a templated URL populated with the provided parameters. + * + * @param serverUrl The server URL to use for all requests. + * @param params The parameters to use when templating the URL. + * @return The builder instance. + */ + public Builder serverURL(String serverUrl, Map params) { + this.serverUrl = Utils.templateUrl(serverUrl, params); + return this; + } + + /** + * Overrides the default server by index. + * + * @param serverIdx The server to use for all requests. + * @return The builder instance. + */ + public Builder serverIndex(int serverIdx) { + this.sdkConfiguration.setServerIdx(serverIdx); + this.serverUrl= SERVERS[serverIdx]; + return this; + } + + /** + * Overrides the default configuration for retries + * + * @param retryConfig The retry configuration to use for all requests. + * @return The builder instance. + */ + public Builder retryConfig(RetryConfig retryConfig) { + this.sdkConfiguration.setRetryConfig(Optional.of(retryConfig)); + return this; + } + + /** + * Enables debug logging for HTTP requests and responses, including JSON body content. + *

+ * Convenience method that calls {@link HTTPClient#enableDebugLogging(boolean)}. + * {@link SpeakeasyHTTPClient} honors this setting. If you are using a custom HTTP client, + * it is up to the custom client to honor this setting. + *

+ * + * @param enabled Whether to enable debug logging. + * @return The builder instance. + */ + public Builder enableHTTPDebugLogging(boolean enabled) { + this.sdkConfiguration.client().enableDebugLogging(enabled); + return this; + } + + + /** + * Allows setting the apiVersion parameter for all supported operations. + * + * @param apiVersion The value to set. + * @return The builder instance. + */ + public Builder apiVersion(String apiVersion) { + this.sdkConfiguration.globals.putParam("pathParam", "api_version", apiVersion); + return this; + } + + /** + * Allows setting the apiRevision parameter for all supported operations. + * + * @param apiRevision The value to set. + * @return The builder instance. + */ + public Builder apiRevision(String apiRevision) { + this.sdkConfiguration.globals.putParam("header", "Api-Revision", apiRevision); + return this; + } + + /** + * Allows setting the userProject parameter for all supported operations. + * + * @param userProject The value to set. + * @return The builder instance. + */ + public Builder userProject(String userProject) { + this.sdkConfiguration.globals.putParam("header", "x-goog-user-project", userProject); + return this; + } + // Visible for testing, may be accessed via reflection in tests + Builder _hooks(com.google.genai.gaos.utils.Hooks hooks) { + sdkConfiguration.setHooks(hooks); + return this; + } + + // Visible for testing, may be accessed via reflection in tests + Builder _hooks(Consumer consumer) { + consumer.accept(sdkConfiguration.hooks()); + return this; + } + + /** + * Builds a new instance of the SDK. + * + * @return The SDK instance. + */ + public GenAI build() { + if (serverUrl == null || serverUrl.isBlank()) { + serverUrl = SERVERS[0]; + sdkConfiguration.setServerIdx(0); + } + sdkConfiguration.setServerUrl(serverUrl); + return new GenAI(sdkConfiguration); + } + } + + /** + * Get a new instance of the SDK builder to configure a new instance of the SDK. + * + * @return The SDK builder instance. + */ + public static Builder builder() { + return new Builder(); + } + + private GenAI(SDKConfiguration sdkConfiguration) { + sdkConfiguration.initialize(); + this.interactions = new Interactions(sdkConfiguration); + this.webhooks = new Webhooks(sdkConfiguration); + this.agents = new Agents(sdkConfiguration); + SdkInitData data = sdkConfiguration.hooks().sdkInit( + new SdkInitData( + sdkConfiguration.resolvedServerUrl(), + sdkConfiguration.client())); + sdkConfiguration.setServerUrl(data.baseUrl()); + sdkConfiguration.setClient(data.client()); + this.asyncSDK = new AsyncGenAI(this, sdkConfiguration); + } + + /** + * Switches to the async SDK. + * + * @return The async SDK + */ + public AsyncGenAI async() { + return asyncSDK; + } + +} diff --git a/src/main/java/com/google/genai/gaos/Interactions.java b/src/main/java/com/google/genai/gaos/Interactions.java new file mode 100644 index 00000000000..ba0bf8ff4fb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/Interactions.java @@ -0,0 +1,254 @@ +/* +* 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; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.models.operations.CancelInteractionByIdRequest; +import com.google.genai.gaos.models.operations.CancelInteractionByIdRequestBuilder; +import com.google.genai.gaos.models.operations.CancelInteractionByIdResponse; +import com.google.genai.gaos.models.operations.CreateInteractionRequest; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBuilder; +import com.google.genai.gaos.models.operations.CreateInteractionResponse; +import com.google.genai.gaos.models.operations.DeleteInteractionRequest; +import com.google.genai.gaos.models.operations.DeleteInteractionRequestBuilder; +import com.google.genai.gaos.models.operations.DeleteInteractionResponse; +import com.google.genai.gaos.models.operations.GetInteractionByIdRequest; +import com.google.genai.gaos.models.operations.GetInteractionByIdRequestBuilder; +import com.google.genai.gaos.models.operations.GetInteractionByIdResponse; +import com.google.genai.gaos.operations.CancelInteractionById; +import com.google.genai.gaos.operations.CreateInteraction; +import com.google.genai.gaos.operations.DeleteInteraction; +import com.google.genai.gaos.operations.GetInteractionById; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class Interactions { + private static final Headers _headers = Headers.EMPTY; + private final SDKConfiguration sdkConfiguration; + private final AsyncInteractions asyncSDK; + + Interactions(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.asyncSDK = new AsyncInteractions(this, sdkConfiguration); + } + + /** + * Switches to the async SDK. + * + * @return The async SDK + */ + public AsyncInteractions async() { + return asyncSDK; + } + + /** + * Creating an interaction + * + *

Creates a new interaction. + * + * @return The call builder + */ + public CreateInteractionRequestBuilder create() { + return new CreateInteractionRequestBuilder(sdkConfiguration); + } + + /** + * Creating an interaction + * + *

Creates a new interaction. + * + * @param body The request body. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public CreateInteractionResponse create(CreateInteractionRequestBody body) { + return create(Optional.empty(), body, Optional.empty()); + } + + /** + * Creating an interaction + * + *

Creates a new interaction. + * + * @param apiVersion Which version of the API to use. + * @param body The request body. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public CreateInteractionResponse create( + Optional apiVersion, CreateInteractionRequestBody body, + Optional options) { + CreateInteractionRequest request = + CreateInteractionRequest + .builder() + .apiVersion(apiVersion) + .body(body) + .build(); + RequestOperation operation + = new CreateInteraction.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Retrieving an interaction + * + *

Retrieves the full details of a single interaction based on its `Interaction.id`. + * + * @return The call builder + */ + public GetInteractionByIdRequestBuilder get() { + return new GetInteractionByIdRequestBuilder(sdkConfiguration); + } + + /** + * Retrieving an interaction + * + *

Retrieves the full details of a single interaction based on its `Interaction.id`. + * + * @param request The request object containing all the parameters for the API call. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public GetInteractionByIdResponse get(GetInteractionByIdRequest request) { + return get(request, Optional.empty()); + } + + /** + * Retrieving an interaction + * + *

Retrieves the full details of a single interaction based on its `Interaction.id`. + * + * @param request The request object containing all the parameters for the API call. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public GetInteractionByIdResponse get(GetInteractionByIdRequest request, Optional options) { + RequestOperation operation + = new GetInteractionById.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Deleting an interaction + * + *

Deletes the interaction by id. + * + * @return The call builder + */ + public DeleteInteractionRequestBuilder delete() { + return new DeleteInteractionRequestBuilder(sdkConfiguration); + } + + /** + * Deleting an interaction + * + *

Deletes the interaction by id. + * + * @param id The unique identifier of the interaction to delete. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public DeleteInteractionResponse delete(String id) { + return delete(id, Optional.empty(), Optional.empty()); + } + + /** + * Deleting an interaction + * + *

Deletes the interaction by id. + * + * @param id The unique identifier of the interaction to delete. + * @param apiVersion Which version of the API to use. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public DeleteInteractionResponse delete( + String id, Optional apiVersion, + Optional options) { + DeleteInteractionRequest request = + DeleteInteractionRequest + .builder() + .id(id) + .apiVersion(apiVersion) + .build(); + RequestOperation operation + = new DeleteInteraction.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Canceling an interaction + * + *

Cancels an interaction by id. This only applies to background interactions that are still running. + * + * @return The call builder + */ + public CancelInteractionByIdRequestBuilder cancel() { + return new CancelInteractionByIdRequestBuilder(sdkConfiguration); + } + + /** + * Canceling an interaction + * + *

Cancels an interaction by id. This only applies to background interactions that are still running. + * + * @param id The unique identifier of the interaction to cancel. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public CancelInteractionByIdResponse cancel(String id) { + return cancel(id, Optional.empty(), Optional.empty()); + } + + /** + * Canceling an interaction + * + *

Cancels an interaction by id. This only applies to background interactions that are still running. + * + * @param id The unique identifier of the interaction to cancel. + * @param apiVersion Which version of the API to use. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public CancelInteractionByIdResponse cancel( + String id, Optional apiVersion, + Optional options) { + CancelInteractionByIdRequest request = + CancelInteractionByIdRequest + .builder() + .id(id) + .apiVersion(apiVersion) + .build(); + RequestOperation operation + = new CancelInteractionById.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + +} diff --git a/src/main/java/com/google/genai/gaos/SDKConfiguration.java b/src/main/java/com/google/genai/gaos/SDKConfiguration.java new file mode 100644 index 00000000000..cc03a1449a8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/SDKConfiguration.java @@ -0,0 +1,163 @@ +/* +* 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; + +import com.google.genai.gaos.hooks.SDKHooks; +import com.google.genai.gaos.utils.AsyncHooks; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.Hooks; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.SpeakeasyHTTPClient; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; + +@SuppressWarnings("all") +public class SDKConfiguration { + + private static final String LANGUAGE = "java"; + public static final String OPENAPI_DOC_VERSION = "v1beta"; + public static final String SDK_VERSION = "0.1.0"; + public static final String GEN_VERSION = "2.913.3"; + private static final String BASE_PACKAGE = "com.google.genai.gaos"; + public static final String USER_AGENT = + String.format("speakeasy-sdk/%s %s %s %s %s", + LANGUAGE, SDK_VERSION, GEN_VERSION, OPENAPI_DOC_VERSION, BASE_PACKAGE); + + private SecuritySource securitySource = SecuritySource.of(null); + + public SecuritySource securitySource() { + return securitySource; + } + + public void setSecuritySource(SecuritySource securitySource) { + Utils.checkNotNull(securitySource, "securitySource"); + this.securitySource = securitySource; + } + + private HTTPClient client = new SpeakeasyHTTPClient(); + + public HTTPClient client() { + return client; + } + + public void setClient(HTTPClient client) { + Utils.checkNotNull(client, "client"); + this.client = client; + } + + private String serverUrl; + + public String serverUrl() { + return serverUrl; + } + + public void setServerUrl(String serverUrl) { + Utils.checkNotNull(serverUrl, "serverUrl"); + this.serverUrl = trimFinalSlash(serverUrl); + } + + private static String trimFinalSlash(String url) { + if (url == null) { + return null; + } else if (url.endsWith("/")) { + return url.substring(0, url.length() - 1); + } else { + return url; + } + } + + public String resolvedServerUrl() { + return serverUrl; + } + + private int serverIdx = 0; + + public void setServerIdx(int serverIdx) { + this.serverIdx = serverIdx; + } + + public int serverIdx() { + return serverIdx; + } + + + private Hooks _hooks = createHooks(); + + private static Hooks createHooks() { + Hooks hooks = new Hooks(); + return hooks; + } + + public Hooks hooks() { + return _hooks; + } + + public void setHooks(Hooks hooks) { + this._hooks = hooks; + } + + /** + * Initializes state (for example hooks). + **/ + public void initialize() { + SDKHooks.initialize(_hooks); + SDKHooks.initialize(_asyncHooks); + } + + @SuppressWarnings("serial") + public Globals globals = new Globals(); + + private Optional retryConfig = Optional.empty(); + + public Optional retryConfig() { + return retryConfig; + } + + public void setRetryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + } + private ScheduledExecutorService retryScheduler = Executors.newSingleThreadScheduledExecutor(); + + public ScheduledExecutorService retryScheduler() { + return retryScheduler; + } + + public void setAsyncRetryScheduler(ScheduledExecutorService retryScheduler) { + Utils.checkNotNull(retryScheduler, "retryScheduler"); + this.retryScheduler = retryScheduler; + } + + private AsyncHooks _asyncHooks = new AsyncHooks(); + + public AsyncHooks asyncHooks() { + return _asyncHooks; + } + + public void setAsyncHooks(AsyncHooks asyncHooks) { + Utils.checkNotNull(asyncHooks, "asyncHooks"); + this._asyncHooks = asyncHooks; + } +} diff --git a/src/main/java/com/google/genai/gaos/SecuritySource.java b/src/main/java/com/google/genai/gaos/SecuritySource.java new file mode 100644 index 00000000000..5efc5d3d5f8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/SecuritySource.java @@ -0,0 +1,44 @@ +/* +* 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; + +import com.google.genai.gaos.utils.HasSecurity; + +@SuppressWarnings("all") +public interface SecuritySource { + + HasSecurity getSecurity(); + + public static SecuritySource of(HasSecurity security) { + return new DefaultSecuritySource(security); + } + + public static class DefaultSecuritySource implements SecuritySource { + private HasSecurity security; + + public DefaultSecuritySource(HasSecurity security) { + this.security = security; + } + + public HasSecurity getSecurity() { + return security; + } + } +} diff --git a/src/main/java/com/google/genai/gaos/Webhooks.java b/src/main/java/com/google/genai/gaos/Webhooks.java new file mode 100644 index 00000000000..4335269b2e9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/Webhooks.java @@ -0,0 +1,405 @@ +/* +* 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; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.models.operations.CreateWebhookRequest; +import com.google.genai.gaos.models.operations.CreateWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.CreateWebhookResponse; +import com.google.genai.gaos.models.operations.DeleteWebhookRequest; +import com.google.genai.gaos.models.operations.DeleteWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.DeleteWebhookResponse; +import com.google.genai.gaos.models.operations.GetWebhookRequest; +import com.google.genai.gaos.models.operations.GetWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.GetWebhookResponse; +import com.google.genai.gaos.models.operations.ListWebhooksRequest; +import com.google.genai.gaos.models.operations.ListWebhooksRequestBuilder; +import com.google.genai.gaos.models.operations.ListWebhooksResponse; +import com.google.genai.gaos.models.operations.PingWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.PingWebhookResponse; +import com.google.genai.gaos.models.operations.RotateSigningSecretRequestBuilder; +import com.google.genai.gaos.models.operations.RotateSigningSecretResponse; +import com.google.genai.gaos.models.operations.UpdateWebhookRequest; +import com.google.genai.gaos.models.operations.UpdateWebhookRequestBuilder; +import com.google.genai.gaos.models.operations.UpdateWebhookResponse; +import com.google.genai.gaos.models.webhooks.PingWebhookRequest; +import com.google.genai.gaos.models.webhooks.RotateSigningSecretRequest; +import com.google.genai.gaos.models.webhooks.WebhookInput; +import com.google.genai.gaos.models.webhooks.WebhookUpdate; +import com.google.genai.gaos.operations.CreateWebhook; +import com.google.genai.gaos.operations.DeleteWebhook; +import com.google.genai.gaos.operations.GetWebhook; +import com.google.genai.gaos.operations.ListWebhooks; +import com.google.genai.gaos.operations.PingWebhook; +import com.google.genai.gaos.operations.RotateSigningSecret; +import com.google.genai.gaos.operations.UpdateWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import java.lang.Integer; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class Webhooks { + private static final Headers _headers = Headers.EMPTY; + private final SDKConfiguration sdkConfiguration; + private final AsyncWebhooks asyncSDK; + + Webhooks(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.asyncSDK = new AsyncWebhooks(this, sdkConfiguration); + } + + /** + * Switches to the async SDK. + * + * @return The async SDK + */ + public AsyncWebhooks async() { + return asyncSDK; + } + + /** + * Creates a new Webhook. + * + * @return The call builder + */ + public CreateWebhookRequestBuilder create() { + return new CreateWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Creates a new Webhook. + * + * @param body A Webhook resource. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public CreateWebhookResponse create(WebhookInput body) { + return create(Optional.empty(), body, Optional.empty()); + } + + /** + * Creates a new Webhook. + * + * @param apiVersion Which version of the API to use. + * @param body A Webhook resource. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public CreateWebhookResponse create( + Optional apiVersion, WebhookInput body, + Optional options) { + CreateWebhookRequest request = + CreateWebhookRequest + .builder() + .apiVersion(apiVersion) + .body(body) + .build(); + RequestOperation operation + = new CreateWebhook.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Lists all Webhooks. + * + * @return The call builder + */ + public ListWebhooksRequestBuilder list() { + return new ListWebhooksRequestBuilder(sdkConfiguration); + } + + /** + * Lists all Webhooks. + * + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public ListWebhooksResponse listDirect() { + return list(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + /** + * Lists all Webhooks. + * + * @param apiVersion Which version of the API to use. + * @param pageSize Optional. The maximum number of webhooks to return. The service may return fewer than + * this value. If unspecified, at most 50 webhooks will be returned. + * The maximum value is 1000. + * @param pageToken Optional. A page token, received from a previous `ListWebhooks` call. + * Provide this to retrieve the subsequent page. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public ListWebhooksResponse list( + Optional apiVersion, Optional pageSize, + Optional pageToken, Optional options) { + ListWebhooksRequest request = + ListWebhooksRequest + .builder() + .apiVersion(apiVersion) + .pageSize(pageSize) + .pageToken(pageToken) + .build(); + RequestOperation operation + = new ListWebhooks.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Gets a specific Webhook. + * + * @return The call builder + */ + public GetWebhookRequestBuilder get() { + return new GetWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Gets a specific Webhook. + * + * @param id Required. The ID of the webhook to retrieve. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public GetWebhookResponse get(String id) { + return get(Optional.empty(), id, Optional.empty()); + } + + /** + * Gets a specific Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook to retrieve. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public GetWebhookResponse get( + Optional apiVersion, String id, + Optional options) { + GetWebhookRequest request = + GetWebhookRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .build(); + RequestOperation operation + = new GetWebhook.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Updates an existing Webhook. + * + * @return The call builder + */ + public UpdateWebhookRequestBuilder update() { + return new UpdateWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Updates an existing Webhook. + * + * @param id Required. The ID of the webhook to update. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public UpdateWebhookResponse update(String id) { + return update(Optional.empty(), id, Optional.empty(), + Optional.empty(), Optional.empty()); + } + + /** + * Updates an existing Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook to update. + * @param updateMask Optional. The list of fields to update. + * @param body + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public UpdateWebhookResponse update( + Optional apiVersion, String id, + Optional updateMask, Optional body, + Optional options) { + UpdateWebhookRequest request = + UpdateWebhookRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .updateMask(updateMask) + .body(body) + .build(); + RequestOperation operation + = new UpdateWebhook.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Deletes a Webhook. + * + * @return The call builder + */ + public DeleteWebhookRequestBuilder delete() { + return new DeleteWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Deletes a Webhook. + * + * @param id Required. The ID of the webhook to delete. + * Format: `{webhook_id}` + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public DeleteWebhookResponse delete(String id) { + return delete(Optional.empty(), id, Optional.empty()); + } + + /** + * Deletes a Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook to delete. + * Format: `{webhook_id}` + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public DeleteWebhookResponse delete( + Optional apiVersion, String id, + Optional options) { + DeleteWebhookRequest request = + DeleteWebhookRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .build(); + RequestOperation operation + = new DeleteWebhook.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Generates a new signing secret for a Webhook. + * + * @return The call builder + */ + public RotateSigningSecretRequestBuilder rotateSigningSecret() { + return new RotateSigningSecretRequestBuilder(sdkConfiguration); + } + + /** + * Generates a new signing secret for a Webhook. + * + * @param id Required. The ID of the webhook for which to generate a signing secret. + * Format: `{webhook_id}` + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public RotateSigningSecretResponse rotateSigningSecret(String id) { + return rotateSigningSecret(Optional.empty(), id, Optional.empty(), + Optional.empty()); + } + + /** + * Generates a new signing secret for a Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook for which to generate a signing secret. + * Format: `{webhook_id}` + * @param body Request message for WebhookService.RotateSigningSecret. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public RotateSigningSecretResponse rotateSigningSecret( + Optional apiVersion, String id, + Optional body, Optional options) { + com.google.genai.gaos.models.operations.RotateSigningSecretRequest request = + com.google.genai.gaos.models.operations.RotateSigningSecretRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .body(body) + .build(); + RequestOperation operation + = new RotateSigningSecret.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + + /** + * Sends a ping event to a Webhook. + * + * @return The call builder + */ + public PingWebhookRequestBuilder ping() { + return new PingWebhookRequestBuilder(sdkConfiguration); + } + + /** + * Sends a ping event to a Webhook. + * + * @param id Required. The ID of the webhook to ping. + * Format: `{webhook_id}` + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public PingWebhookResponse ping(String id) { + return ping(Optional.empty(), id, Optional.empty(), + Optional.empty()); + } + + /** + * Sends a ping event to a Webhook. + * + * @param apiVersion Which version of the API to use. + * @param id Required. The ID of the webhook to ping. + * Format: `{webhook_id}` + * @param body Request message for WebhookService.PingWebhook. + * @param options additional options + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public PingWebhookResponse ping( + Optional apiVersion, String id, + Optional body, Optional options) { + com.google.genai.gaos.models.operations.PingWebhookRequest request = + com.google.genai.gaos.models.operations.PingWebhookRequest + .builder() + .apiVersion(apiVersion) + .id(id) + .body(body) + .build(); + RequestOperation operation + = new PingWebhook.Sync(sdkConfiguration, options, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + +} diff --git a/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java b/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java new file mode 100644 index 00000000000..692f34adbec --- /dev/null +++ b/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java @@ -0,0 +1,91 @@ +/* +* 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. +*/ + +package com.google.genai.gaos.hooks; + +import com.google.genai.gaos.models.shared.Security; +import com.google.genai.gaos.utils.HasSecurity; +import com.google.genai.gaos.utils.Helpers; +import java.net.http.HttpRequest; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +// +// This file is written once by speakeasy code generation and +// thereafter will not be overwritten by speakeasy updates. As a +// consequence any customization of this class will be preserved. +// + +@SuppressWarnings("all") +public final class SDKHooks { + + private SDKHooks() { + // prevent instantiation + } + + 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 = Helpers.copy(request); + + 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(); + } + } + 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 = Helpers.copy(request); + + 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()); + } + } + return CompletableFuture.completedFuture(request); + }); + } + +} diff --git a/src/main/java/com/google/genai/gaos/models/agents/Agent.java b/src/main/java/com/google/genai/gaos/models/agents/Agent.java new file mode 100644 index 00000000000..c2d036cff03 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/agents/Agent.java @@ -0,0 +1,465 @@ +/* +* 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.agents; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * Agent + * + *

An agent definition for the CreateAgent API. + * This message is the target for annotation-parser-based JSON parsing. + * New format: + * { + * "id": "customer-sentinel", + * "base_agent": "", + * "system_instruction": "...", + * "base_environment": { "type": "remote", "sources": [...] }, + * "tools": [ {"type": "code_execution"} ] + * } + */ +@SuppressWarnings("all") +public class Agent { + /** + * The unique identifier for the agent. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("id") + private Optional id; + + /** + * The base agent to extend. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("base_agent") + private Optional baseAgent; + + /** + * System instruction for the agent. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("system_instruction") + private Optional systemInstruction; + + /** + * Agent description for developers to quickly read and understand. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("description") + private Optional description; + + /** + * The tools available to the agent. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("tools") + private Optional> tools; + + /** + * The environment configuration for the agent. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("base_environment") + private Optional baseEnvironment; + + @JsonCreator + public Agent( + @JsonProperty("id") Optional id, + @JsonProperty("base_agent") Optional baseAgent, + @JsonProperty("system_instruction") Optional systemInstruction, + @JsonProperty("description") Optional description, + @JsonProperty("tools") Optional> tools, + @JsonProperty("base_environment") Optional baseEnvironment) { + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(baseAgent, "baseAgent"); + Utils.checkNotNull(systemInstruction, "systemInstruction"); + Utils.checkNotNull(description, "description"); + Utils.checkNotNull(tools, "tools"); + Utils.checkNotNull(baseEnvironment, "baseEnvironment"); + this.id = id; + this.baseAgent = baseAgent; + this.systemInstruction = systemInstruction; + this.description = description; + this.tools = tools; + this.baseEnvironment = baseEnvironment; + } + + public Agent() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * The unique identifier for the agent. + */ + @JsonIgnore + public Optional id() { + return id; + } + + /** + * The base agent to extend. + */ + @JsonIgnore + public Optional baseAgent() { + return baseAgent; + } + + /** + * System instruction for the agent. + */ + @JsonIgnore + public Optional systemInstruction() { + return systemInstruction; + } + + /** + * Agent description for developers to quickly read and understand. + */ + @JsonIgnore + public Optional description() { + return description; + } + + /** + * The tools available to the agent. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> tools() { + return (Optional>) tools; + } + + /** + * The environment configuration for the agent. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional baseEnvironment() { + return (Optional) baseEnvironment; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The unique identifier for the agent. + */ + public Agent withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = Optional.ofNullable(id); + return this; + } + + + /** + * The unique identifier for the agent. + */ + public Agent withId(Optional id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * The base agent to extend. + */ + public Agent withBaseAgent(String baseAgent) { + Utils.checkNotNull(baseAgent, "baseAgent"); + this.baseAgent = Optional.ofNullable(baseAgent); + return this; + } + + + /** + * The base agent to extend. + */ + public Agent withBaseAgent(Optional baseAgent) { + Utils.checkNotNull(baseAgent, "baseAgent"); + this.baseAgent = baseAgent; + return this; + } + + /** + * System instruction for the agent. + */ + public Agent withSystemInstruction(String systemInstruction) { + Utils.checkNotNull(systemInstruction, "systemInstruction"); + this.systemInstruction = Optional.ofNullable(systemInstruction); + return this; + } + + + /** + * System instruction for the agent. + */ + public Agent withSystemInstruction(Optional systemInstruction) { + Utils.checkNotNull(systemInstruction, "systemInstruction"); + this.systemInstruction = systemInstruction; + return this; + } + + /** + * Agent description for developers to quickly read and understand. + */ + public Agent withDescription(String description) { + Utils.checkNotNull(description, "description"); + this.description = Optional.ofNullable(description); + return this; + } + + + /** + * Agent description for developers to quickly read and understand. + */ + public Agent withDescription(Optional description) { + Utils.checkNotNull(description, "description"); + this.description = description; + return this; + } + + /** + * The tools available to the agent. + */ + public Agent withTools(List tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = Optional.ofNullable(tools); + return this; + } + + + /** + * The tools available to the agent. + */ + public Agent withTools(Optional> tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = tools; + return this; + } + + /** + * The environment configuration for the agent. + */ + public Agent withBaseEnvironment(BaseEnvironment baseEnvironment) { + Utils.checkNotNull(baseEnvironment, "baseEnvironment"); + this.baseEnvironment = Optional.ofNullable(baseEnvironment); + return this; + } + + + /** + * The environment configuration for the agent. + */ + public Agent withBaseEnvironment(Optional baseEnvironment) { + Utils.checkNotNull(baseEnvironment, "baseEnvironment"); + this.baseEnvironment = baseEnvironment; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Agent other = (Agent) o; + return + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.baseAgent, other.baseAgent) && + Utils.enhancedDeepEquals(this.systemInstruction, other.systemInstruction) && + Utils.enhancedDeepEquals(this.description, other.description) && + Utils.enhancedDeepEquals(this.tools, other.tools) && + Utils.enhancedDeepEquals(this.baseEnvironment, other.baseEnvironment); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + id, baseAgent, systemInstruction, + description, tools, baseEnvironment); + } + + @Override + public String toString() { + return Utils.toString(Agent.class, + "id", id, + "baseAgent", baseAgent, + "systemInstruction", systemInstruction, + "description", description, + "tools", tools, + "baseEnvironment", baseEnvironment); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional id = Optional.empty(); + + private Optional baseAgent = Optional.empty(); + + private Optional systemInstruction = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional> tools = Optional.empty(); + + private Optional baseEnvironment = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The unique identifier for the agent. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = Optional.ofNullable(id); + return this; + } + + /** + * The unique identifier for the agent. + */ + public Builder id(Optional id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * The base agent to extend. + */ + public Builder baseAgent(String baseAgent) { + Utils.checkNotNull(baseAgent, "baseAgent"); + this.baseAgent = Optional.ofNullable(baseAgent); + return this; + } + + /** + * The base agent to extend. + */ + public Builder baseAgent(Optional baseAgent) { + Utils.checkNotNull(baseAgent, "baseAgent"); + this.baseAgent = baseAgent; + return this; + } + + + /** + * System instruction for the agent. + */ + public Builder systemInstruction(String systemInstruction) { + Utils.checkNotNull(systemInstruction, "systemInstruction"); + this.systemInstruction = Optional.ofNullable(systemInstruction); + return this; + } + + /** + * System instruction for the agent. + */ + public Builder systemInstruction(Optional systemInstruction) { + Utils.checkNotNull(systemInstruction, "systemInstruction"); + this.systemInstruction = systemInstruction; + return this; + } + + + /** + * Agent description for developers to quickly read and understand. + */ + public Builder description(String description) { + Utils.checkNotNull(description, "description"); + this.description = Optional.ofNullable(description); + return this; + } + + /** + * Agent description for developers to quickly read and understand. + */ + public Builder description(Optional description) { + Utils.checkNotNull(description, "description"); + this.description = description; + return this; + } + + + /** + * The tools available to the agent. + */ + public Builder tools(List tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = Optional.ofNullable(tools); + return this; + } + + /** + * The tools available to the agent. + */ + public Builder tools(Optional> tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = tools; + return this; + } + + + /** + * The environment configuration for the agent. + */ + public Builder baseEnvironment(BaseEnvironment baseEnvironment) { + Utils.checkNotNull(baseEnvironment, "baseEnvironment"); + this.baseEnvironment = Optional.ofNullable(baseEnvironment); + return this; + } + + /** + * The environment configuration for the agent. + */ + public Builder baseEnvironment(Optional baseEnvironment) { + Utils.checkNotNull(baseEnvironment, "baseEnvironment"); + this.baseEnvironment = baseEnvironment; + return this; + } + + public Agent build() { + + return new Agent( + id, baseAgent, systemInstruction, + description, tools, baseEnvironment); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/agents/AgentListResponse.java b/src/main/java/com/google/genai/gaos/models/agents/AgentListResponse.java new file mode 100644 index 00000000000..12f15bb3e34 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/agents/AgentListResponse.java @@ -0,0 +1,174 @@ +/* +* 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.agents; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + + +@SuppressWarnings("all") +public class AgentListResponse { + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("agents") + private Optional> agents; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("next_page_token") + private Optional nextPageToken; + + @JsonCreator + public AgentListResponse( + @JsonProperty("agents") Optional> agents, + @JsonProperty("next_page_token") Optional nextPageToken) { + Utils.checkNotNull(agents, "agents"); + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.agents = agents; + this.nextPageToken = nextPageToken; + } + + public AgentListResponse() { + this(Optional.empty(), Optional.empty()); + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> agents() { + return (Optional>) agents; + } + + @JsonIgnore + public Optional nextPageToken() { + return nextPageToken; + } + + public static Builder builder() { + return new Builder(); + } + + + public AgentListResponse withAgents(List agents) { + Utils.checkNotNull(agents, "agents"); + this.agents = Optional.ofNullable(agents); + return this; + } + + + public AgentListResponse withAgents(Optional> agents) { + Utils.checkNotNull(agents, "agents"); + this.agents = agents; + return this; + } + + public AgentListResponse withNextPageToken(String nextPageToken) { + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.nextPageToken = Optional.ofNullable(nextPageToken); + return this; + } + + + public AgentListResponse withNextPageToken(Optional nextPageToken) { + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.nextPageToken = nextPageToken; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AgentListResponse other = (AgentListResponse) o; + return + Utils.enhancedDeepEquals(this.agents, other.agents) && + Utils.enhancedDeepEquals(this.nextPageToken, other.nextPageToken); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + agents, nextPageToken); + } + + @Override + public String toString() { + return Utils.toString(AgentListResponse.class, + "agents", agents, + "nextPageToken", nextPageToken); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> agents = Optional.empty(); + + private Optional nextPageToken = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder agents(List agents) { + Utils.checkNotNull(agents, "agents"); + this.agents = Optional.ofNullable(agents); + return this; + } + + public Builder agents(Optional> agents) { + Utils.checkNotNull(agents, "agents"); + this.agents = agents; + return this; + } + + + public Builder nextPageToken(String nextPageToken) { + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.nextPageToken = Optional.ofNullable(nextPageToken); + return this; + } + + public Builder nextPageToken(Optional nextPageToken) { + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.nextPageToken = nextPageToken; + return this; + } + + public AgentListResponse build() { + + return new AgentListResponse( + agents, nextPageToken); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/agents/AgentTool.java b/src/main/java/com/google/genai/gaos/models/agents/AgentTool.java new file mode 100644 index 00000000000..213083c3c13 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/agents/AgentTool.java @@ -0,0 +1,134 @@ +/* +* 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.agents; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.genai.gaos.models.interactions.CodeExecution; +import com.google.genai.gaos.models.interactions.GoogleSearch; +import com.google.genai.gaos.models.interactions.MCPServer; +import com.google.genai.gaos.models.interactions.URLContext; +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; + +/** + * AgentTool + * + *

A tool that the agent can use. + */ +@JsonDeserialize(using = AgentTool._Deserializer.class) +@SuppressWarnings("all") +public class AgentTool { + + @JsonValue + private final TypedObject value; + + private AgentTool(TypedObject value) { + this.value = value; + } + + public static AgentTool of(CodeExecution value) { + Utils.checkNotNull(value, "value"); + return new AgentTool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static AgentTool of(GoogleSearch value) { + Utils.checkNotNull(value, "value"); + return new AgentTool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static AgentTool of(URLContext value) { + Utils.checkNotNull(value, "value"); + return new AgentTool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static AgentTool of(MCPServer value) { + Utils.checkNotNull(value, "value"); + return new AgentTool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AgentTool other = (AgentTool) 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(AgentTool.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(AgentTool.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/agents/BaseEnvironment.java b/src/main/java/com/google/genai/gaos/models/agents/BaseEnvironment.java new file mode 100644 index 00000000000..f0560e9aaa0 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/agents/BaseEnvironment.java @@ -0,0 +1,117 @@ +/* +* 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.agents; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.genai.gaos.models.interactions.Environment; +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; + +/** + * BaseEnvironment + * + *

The environment configuration for the agent. + */ +@JsonDeserialize(using = BaseEnvironment._Deserializer.class) +@SuppressWarnings("all") +public class BaseEnvironment { + + @JsonValue + private final TypedObject value; + + private BaseEnvironment(TypedObject value) { + this.value = value; + } + + public static BaseEnvironment of(Environment value) { + Utils.checkNotNull(value, "value"); + return new BaseEnvironment(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static BaseEnvironment of(String value) { + Utils.checkNotNull(value, "value"); + return new BaseEnvironment(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.Environment}
  • + *
  • {@code java.lang.String}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseEnvironment other = (BaseEnvironment) 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(BaseEnvironment.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(BaseEnvironment.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/errors/AsyncSDKException.java b/src/main/java/com/google/genai/gaos/models/errors/AsyncSDKException.java new file mode 100644 index 00000000000..d26f9c0085b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/AsyncSDKException.java @@ -0,0 +1,48 @@ +/* +* 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.errors; + +import jakarta.annotation.Nullable; +import java.net.http.HttpResponse; +import com.google.genai.gaos.utils.Blob; + +/** + * Thrown by an async service call when an error response occurs. Contains details about the response. + * This is an unchecked exception suitable for use in CompletableFuture chains. + */ +@SuppressWarnings({"serial", "all"}) +public class AsyncSDKException extends GenAiException { + + public AsyncSDKException( + String message, + int code, + @Nullable byte[] body, + HttpResponse rawResponse, + @Nullable Throwable cause) { + super(message, code, body, rawResponse, cause); + } + + @SuppressWarnings("unchecked") + @Override + public HttpResponse rawResponse() { + return (HttpResponse) super.rawResponse(); + } + +} \ No newline at end of file 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 new file mode 100644 index 00000000000..93113e17740 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/AuthException.java @@ -0,0 +1,51 @@ +/* +* 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.errors; + +import java.io.InputStream; +import java.net.http.HttpResponse; +import java.util.Optional; + +/** + * An exception associated with Authentication or Authorization. + */ +@SuppressWarnings({"serial", "all"}) +public class AuthException extends GenAiException { + + public AuthException(String message, int code, byte[] body, HttpResponse rawResponse) { + super(message, code, body, rawResponse, null); + } + + /** + * Returns the HTTP status code of the response. + * + * @deprecated Use {@link #code()} instead. + */ + @Deprecated + public Optional statusCode() { + return Optional.of(super.code()); + } + + @SuppressWarnings("unchecked") + @Override + public HttpResponse rawResponse() { + return (HttpResponse) super.rawResponse(); + } +} 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 new file mode 100644 index 00000000000..67ea5182a88 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdClientError.java @@ -0,0 +1,226 @@ +/* +* 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.errors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Error; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.io.InputStream; +import java.lang.Deprecated; +import java.lang.Exception; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Throwable; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@SuppressWarnings({"serial", "all"}) +public class CancelInteractionByIdClientError extends GenAiException { + + @Nullable + private final Data data; + + @Nullable + private final Throwable deserializationException; + + public CancelInteractionByIdClientError( + int code, + byte[] body, + HttpResponse rawResponse, + @Nullable Data data, + @Nullable Throwable deserializationException) { + super("API error occurred", code, body, rawResponse, null); + this.data = data; + this.deserializationException = deserializationException; + } + + /** + * Parse a response into an instance of CancelInteractionByIdClientError. If deserialization of the response body fails, + * the resulting CancelInteractionByIdClientError instance will have a null data() value and a non-null deserializationException(). + */ + public static CancelInteractionByIdClientError from(HttpResponse response) { + try { + byte[] bytes = Utils.extractByteArrayFromBody(response); + Data data = Utils.mapper().readValue(bytes, Data.class); + return new CancelInteractionByIdClientError(response.statusCode(), bytes, response, data, null); + } catch (Exception e) { + return new CancelInteractionByIdClientError(response.statusCode(), null, response, null, e); + } + } + + /** + * Parse a response into an instance of CancelInteractionByIdClientError asynchronously. If deserialization of the response body fails, + * the resulting CancelInteractionByIdClientError instance will have a null data() value and a non-null deserializationException(). + */ + public static CompletableFuture fromAsync(HttpResponse response) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + + try { + return new CancelInteractionByIdClientError( + response.statusCode(), + bytes, + response, + Utils.mapper().readValue( + bytes, + new TypeReference() { + }), + null); + } catch (Exception e) { + return new CancelInteractionByIdClientError( + response.statusCode(), + bytes, + response, + null, + e); + } + }); + } + + /** + * Error message from an interaction. + */ + @Deprecated + public Optional error() { + return data().map(Data::error); + } + + public Optional data() { + return Optional.ofNullable(data); + } + + /** + * Returns the exception if an error occurs while deserializing the response body. + */ + public Optional deserializationException() { + return Optional.ofNullable(deserializationException); + } + /** + * Data + * + *

Error cancelling interaction + */ + public static class Data { + /** + * Error message from an interaction. + */ + @JsonProperty("error") + private Error error; + + @JsonCreator + public Data( + @JsonProperty("error") Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + } + + /** + * Error message from an interaction. + */ + @JsonIgnore + public Error error() { + return error; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public Data withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Data other = (Data) o; + return + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + error); + } + + @Override + public String toString() { + return Utils.toString(Data.class, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Error error; + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public Data build() { + + return new Data( + error); + } + + } + } + +} + 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 new file mode 100644 index 00000000000..4b757082733 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdServerError.java @@ -0,0 +1,226 @@ +/* +* 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.errors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Error; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.io.InputStream; +import java.lang.Deprecated; +import java.lang.Exception; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Throwable; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@SuppressWarnings({"serial", "all"}) +public class CancelInteractionByIdServerError extends GenAiException { + + @Nullable + private final Data data; + + @Nullable + private final Throwable deserializationException; + + public CancelInteractionByIdServerError( + int code, + byte[] body, + HttpResponse rawResponse, + @Nullable Data data, + @Nullable Throwable deserializationException) { + super("API error occurred", code, body, rawResponse, null); + this.data = data; + this.deserializationException = deserializationException; + } + + /** + * Parse a response into an instance of CancelInteractionByIdServerError. If deserialization of the response body fails, + * the resulting CancelInteractionByIdServerError instance will have a null data() value and a non-null deserializationException(). + */ + public static CancelInteractionByIdServerError from(HttpResponse response) { + try { + byte[] bytes = Utils.extractByteArrayFromBody(response); + Data data = Utils.mapper().readValue(bytes, Data.class); + return new CancelInteractionByIdServerError(response.statusCode(), bytes, response, data, null); + } catch (Exception e) { + return new CancelInteractionByIdServerError(response.statusCode(), null, response, null, e); + } + } + + /** + * Parse a response into an instance of CancelInteractionByIdServerError asynchronously. If deserialization of the response body fails, + * the resulting CancelInteractionByIdServerError instance will have a null data() value and a non-null deserializationException(). + */ + public static CompletableFuture fromAsync(HttpResponse response) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + + try { + return new CancelInteractionByIdServerError( + response.statusCode(), + bytes, + response, + Utils.mapper().readValue( + bytes, + new TypeReference() { + }), + null); + } catch (Exception e) { + return new CancelInteractionByIdServerError( + response.statusCode(), + bytes, + response, + null, + e); + } + }); + } + + /** + * Error message from an interaction. + */ + @Deprecated + public Optional error() { + return data().map(Data::error); + } + + public Optional data() { + return Optional.ofNullable(data); + } + + /** + * Returns the exception if an error occurs while deserializing the response body. + */ + public Optional deserializationException() { + return Optional.ofNullable(deserializationException); + } + /** + * Data + * + *

Error cancelling interaction + */ + public static class Data { + /** + * Error message from an interaction. + */ + @JsonProperty("error") + private Error error; + + @JsonCreator + public Data( + @JsonProperty("error") Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + } + + /** + * Error message from an interaction. + */ + @JsonIgnore + public Error error() { + return error; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public Data withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Data other = (Data) o; + return + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + error); + } + + @Override + public String toString() { + return Utils.toString(Data.class, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Error error; + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public Data build() { + + return new Data( + error); + } + + } + } + +} + 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 new file mode 100644 index 00000000000..3aad9e06d56 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionClientError.java @@ -0,0 +1,226 @@ +/* +* 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.errors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Error; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.io.InputStream; +import java.lang.Deprecated; +import java.lang.Exception; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Throwable; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@SuppressWarnings({"serial", "all"}) +public class CreateInteractionClientError extends GenAiException { + + @Nullable + private final Data data; + + @Nullable + private final Throwable deserializationException; + + public CreateInteractionClientError( + int code, + byte[] body, + HttpResponse rawResponse, + @Nullable Data data, + @Nullable Throwable deserializationException) { + super("API error occurred", code, body, rawResponse, null); + this.data = data; + this.deserializationException = deserializationException; + } + + /** + * Parse a response into an instance of CreateInteractionClientError. If deserialization of the response body fails, + * the resulting CreateInteractionClientError instance will have a null data() value and a non-null deserializationException(). + */ + public static CreateInteractionClientError from(HttpResponse response) { + try { + byte[] bytes = Utils.extractByteArrayFromBody(response); + Data data = Utils.mapper().readValue(bytes, Data.class); + return new CreateInteractionClientError(response.statusCode(), bytes, response, data, null); + } catch (Exception e) { + return new CreateInteractionClientError(response.statusCode(), null, response, null, e); + } + } + + /** + * Parse a response into an instance of CreateInteractionClientError asynchronously. If deserialization of the response body fails, + * the resulting CreateInteractionClientError instance will have a null data() value and a non-null deserializationException(). + */ + public static CompletableFuture fromAsync(HttpResponse response) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + + try { + return new CreateInteractionClientError( + response.statusCode(), + bytes, + response, + Utils.mapper().readValue( + bytes, + new TypeReference() { + }), + null); + } catch (Exception e) { + return new CreateInteractionClientError( + response.statusCode(), + bytes, + response, + null, + e); + } + }); + } + + /** + * Error message from an interaction. + */ + @Deprecated + public Optional error() { + return data().map(Data::error); + } + + public Optional data() { + return Optional.ofNullable(data); + } + + /** + * Returns the exception if an error occurs while deserializing the response body. + */ + public Optional deserializationException() { + return Optional.ofNullable(deserializationException); + } + /** + * Data + * + *

Error creating interaction + */ + public static class Data { + /** + * Error message from an interaction. + */ + @JsonProperty("error") + private Error error; + + @JsonCreator + public Data( + @JsonProperty("error") Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + } + + /** + * Error message from an interaction. + */ + @JsonIgnore + public Error error() { + return error; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public Data withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Data other = (Data) o; + return + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + error); + } + + @Override + public String toString() { + return Utils.toString(Data.class, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Error error; + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public Data build() { + + return new Data( + error); + } + + } + } + +} + 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 new file mode 100644 index 00000000000..5b98268ff4f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionServerError.java @@ -0,0 +1,226 @@ +/* +* 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.errors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Error; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.io.InputStream; +import java.lang.Deprecated; +import java.lang.Exception; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Throwable; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@SuppressWarnings({"serial", "all"}) +public class CreateInteractionServerError extends GenAiException { + + @Nullable + private final Data data; + + @Nullable + private final Throwable deserializationException; + + public CreateInteractionServerError( + int code, + byte[] body, + HttpResponse rawResponse, + @Nullable Data data, + @Nullable Throwable deserializationException) { + super("API error occurred", code, body, rawResponse, null); + this.data = data; + this.deserializationException = deserializationException; + } + + /** + * Parse a response into an instance of CreateInteractionServerError. If deserialization of the response body fails, + * the resulting CreateInteractionServerError instance will have a null data() value and a non-null deserializationException(). + */ + public static CreateInteractionServerError from(HttpResponse response) { + try { + byte[] bytes = Utils.extractByteArrayFromBody(response); + Data data = Utils.mapper().readValue(bytes, Data.class); + return new CreateInteractionServerError(response.statusCode(), bytes, response, data, null); + } catch (Exception e) { + return new CreateInteractionServerError(response.statusCode(), null, response, null, e); + } + } + + /** + * Parse a response into an instance of CreateInteractionServerError asynchronously. If deserialization of the response body fails, + * the resulting CreateInteractionServerError instance will have a null data() value and a non-null deserializationException(). + */ + public static CompletableFuture fromAsync(HttpResponse response) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + + try { + return new CreateInteractionServerError( + response.statusCode(), + bytes, + response, + Utils.mapper().readValue( + bytes, + new TypeReference() { + }), + null); + } catch (Exception e) { + return new CreateInteractionServerError( + response.statusCode(), + bytes, + response, + null, + e); + } + }); + } + + /** + * Error message from an interaction. + */ + @Deprecated + public Optional error() { + return data().map(Data::error); + } + + public Optional data() { + return Optional.ofNullable(data); + } + + /** + * Returns the exception if an error occurs while deserializing the response body. + */ + public Optional deserializationException() { + return Optional.ofNullable(deserializationException); + } + /** + * Data + * + *

Error creating interaction + */ + public static class Data { + /** + * Error message from an interaction. + */ + @JsonProperty("error") + private Error error; + + @JsonCreator + public Data( + @JsonProperty("error") Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + } + + /** + * Error message from an interaction. + */ + @JsonIgnore + public Error error() { + return error; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public Data withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Data other = (Data) o; + return + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + error); + } + + @Override + public String toString() { + return Utils.toString(Data.class, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Error error; + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public Data build() { + + return new Data( + error); + } + + } + } + +} + 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 new file mode 100644 index 00000000000..c051d998b9d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionClientError.java @@ -0,0 +1,226 @@ +/* +* 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.errors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Error; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.io.InputStream; +import java.lang.Deprecated; +import java.lang.Exception; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Throwable; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@SuppressWarnings({"serial", "all"}) +public class DeleteInteractionClientError extends GenAiException { + + @Nullable + private final Data data; + + @Nullable + private final Throwable deserializationException; + + public DeleteInteractionClientError( + int code, + byte[] body, + HttpResponse rawResponse, + @Nullable Data data, + @Nullable Throwable deserializationException) { + super("API error occurred", code, body, rawResponse, null); + this.data = data; + this.deserializationException = deserializationException; + } + + /** + * Parse a response into an instance of DeleteInteractionClientError. If deserialization of the response body fails, + * the resulting DeleteInteractionClientError instance will have a null data() value and a non-null deserializationException(). + */ + public static DeleteInteractionClientError from(HttpResponse response) { + try { + byte[] bytes = Utils.extractByteArrayFromBody(response); + Data data = Utils.mapper().readValue(bytes, Data.class); + return new DeleteInteractionClientError(response.statusCode(), bytes, response, data, null); + } catch (Exception e) { + return new DeleteInteractionClientError(response.statusCode(), null, response, null, e); + } + } + + /** + * Parse a response into an instance of DeleteInteractionClientError asynchronously. If deserialization of the response body fails, + * the resulting DeleteInteractionClientError instance will have a null data() value and a non-null deserializationException(). + */ + public static CompletableFuture fromAsync(HttpResponse response) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + + try { + return new DeleteInteractionClientError( + response.statusCode(), + bytes, + response, + Utils.mapper().readValue( + bytes, + new TypeReference() { + }), + null); + } catch (Exception e) { + return new DeleteInteractionClientError( + response.statusCode(), + bytes, + response, + null, + e); + } + }); + } + + /** + * Error message from an interaction. + */ + @Deprecated + public Optional error() { + return data().map(Data::error); + } + + public Optional data() { + return Optional.ofNullable(data); + } + + /** + * Returns the exception if an error occurs while deserializing the response body. + */ + public Optional deserializationException() { + return Optional.ofNullable(deserializationException); + } + /** + * Data + * + *

Error deleting interaction + */ + public static class Data { + /** + * Error message from an interaction. + */ + @JsonProperty("error") + private Error error; + + @JsonCreator + public Data( + @JsonProperty("error") Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + } + + /** + * Error message from an interaction. + */ + @JsonIgnore + public Error error() { + return error; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public Data withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Data other = (Data) o; + return + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + error); + } + + @Override + public String toString() { + return Utils.toString(Data.class, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Error error; + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public Data build() { + + return new Data( + error); + } + + } + } + +} + 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 new file mode 100644 index 00000000000..ba3886b46d9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionServerError.java @@ -0,0 +1,226 @@ +/* +* 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.errors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Error; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.io.InputStream; +import java.lang.Deprecated; +import java.lang.Exception; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Throwable; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@SuppressWarnings({"serial", "all"}) +public class DeleteInteractionServerError extends GenAiException { + + @Nullable + private final Data data; + + @Nullable + private final Throwable deserializationException; + + public DeleteInteractionServerError( + int code, + byte[] body, + HttpResponse rawResponse, + @Nullable Data data, + @Nullable Throwable deserializationException) { + super("API error occurred", code, body, rawResponse, null); + this.data = data; + this.deserializationException = deserializationException; + } + + /** + * Parse a response into an instance of DeleteInteractionServerError. If deserialization of the response body fails, + * the resulting DeleteInteractionServerError instance will have a null data() value and a non-null deserializationException(). + */ + public static DeleteInteractionServerError from(HttpResponse response) { + try { + byte[] bytes = Utils.extractByteArrayFromBody(response); + Data data = Utils.mapper().readValue(bytes, Data.class); + return new DeleteInteractionServerError(response.statusCode(), bytes, response, data, null); + } catch (Exception e) { + return new DeleteInteractionServerError(response.statusCode(), null, response, null, e); + } + } + + /** + * Parse a response into an instance of DeleteInteractionServerError asynchronously. If deserialization of the response body fails, + * the resulting DeleteInteractionServerError instance will have a null data() value and a non-null deserializationException(). + */ + public static CompletableFuture fromAsync(HttpResponse response) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + + try { + return new DeleteInteractionServerError( + response.statusCode(), + bytes, + response, + Utils.mapper().readValue( + bytes, + new TypeReference() { + }), + null); + } catch (Exception e) { + return new DeleteInteractionServerError( + response.statusCode(), + bytes, + response, + null, + e); + } + }); + } + + /** + * Error message from an interaction. + */ + @Deprecated + public Optional error() { + return data().map(Data::error); + } + + public Optional data() { + return Optional.ofNullable(data); + } + + /** + * Returns the exception if an error occurs while deserializing the response body. + */ + public Optional deserializationException() { + return Optional.ofNullable(deserializationException); + } + /** + * Data + * + *

Error deleting interaction + */ + public static class Data { + /** + * Error message from an interaction. + */ + @JsonProperty("error") + private Error error; + + @JsonCreator + public Data( + @JsonProperty("error") Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + } + + /** + * Error message from an interaction. + */ + @JsonIgnore + public Error error() { + return error; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public Data withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Data other = (Data) o; + return + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + error); + } + + @Override + public String toString() { + return Utils.toString(Data.class, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Error error; + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public Data build() { + + return new Data( + error); + } + + } + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/errors/GenAiException.java b/src/main/java/com/google/genai/gaos/models/errors/GenAiException.java new file mode 100644 index 00000000000..f89a2826dd7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/GenAiException.java @@ -0,0 +1,110 @@ +/* +* 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.errors; + +import com.google.genai.gaos.utils.Utils; +import com.google.genai.gaos.utils.Headers; + +import jakarta.annotation.Nullable; + +import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.util.Optional; +@SuppressWarnings({"serial", "all"}) +public abstract class GenAiException extends RuntimeException { + + 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); + Utils.checkNotNull(message, "message"); + Utils.checkNotNull(rawResponse, "rawResponse"); + this.body = body; + this.code = code; + this.rawResponse = rawResponse; + } + + public Optional body() { + return Optional.ofNullable(body); + } + + public Optional bodyAsString() { + return body().map(x -> new String(x, StandardCharsets.UTF_8)); + } + + public int code() { + return code; + } + + /** + * Returns the raw HTTP response associated with this exception. The response body stream + * may not be available (but the body can be accessed via the {@code body()} method). + * + * @return the raw HTTP response + */ + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Returns the headers from the raw HTTP response as a map. + * + * @return response headers + */ + public Headers headers() { + return new Headers(rawResponse.headers().map()); + } + + // present for backwards compatibility + public String message() { + return getMessage(); + } + + public GenAiException withCode(int code) { + this.code = code; + return this; + } + + public GenAiException withBody(@Nullable byte[] body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public GenAiException withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + @Override + public String toString() { + return Utils.toString(this.getClass(), + "requestMethod", rawResponse.request().method(), + "requestUri", rawResponse.request().uri(), + "code", code, + "responseHeaders", rawResponse.headers().map(), + "message", getMessage(), + "body", bodyAsString().orElse("null")); + } +} + 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 new file mode 100644 index 00000000000..86afbe5a5c2 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdClientError.java @@ -0,0 +1,226 @@ +/* +* 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.errors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Error; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.io.InputStream; +import java.lang.Deprecated; +import java.lang.Exception; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Throwable; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@SuppressWarnings({"serial", "all"}) +public class GetInteractionByIdClientError extends GenAiException { + + @Nullable + private final Data data; + + @Nullable + private final Throwable deserializationException; + + public GetInteractionByIdClientError( + int code, + byte[] body, + HttpResponse rawResponse, + @Nullable Data data, + @Nullable Throwable deserializationException) { + super("API error occurred", code, body, rawResponse, null); + this.data = data; + this.deserializationException = deserializationException; + } + + /** + * Parse a response into an instance of GetInteractionByIdClientError. If deserialization of the response body fails, + * the resulting GetInteractionByIdClientError instance will have a null data() value and a non-null deserializationException(). + */ + public static GetInteractionByIdClientError from(HttpResponse response) { + try { + byte[] bytes = Utils.extractByteArrayFromBody(response); + Data data = Utils.mapper().readValue(bytes, Data.class); + return new GetInteractionByIdClientError(response.statusCode(), bytes, response, data, null); + } catch (Exception e) { + return new GetInteractionByIdClientError(response.statusCode(), null, response, null, e); + } + } + + /** + * Parse a response into an instance of GetInteractionByIdClientError asynchronously. If deserialization of the response body fails, + * the resulting GetInteractionByIdClientError instance will have a null data() value and a non-null deserializationException(). + */ + public static CompletableFuture fromAsync(HttpResponse response) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + + try { + return new GetInteractionByIdClientError( + response.statusCode(), + bytes, + response, + Utils.mapper().readValue( + bytes, + new TypeReference() { + }), + null); + } catch (Exception e) { + return new GetInteractionByIdClientError( + response.statusCode(), + bytes, + response, + null, + e); + } + }); + } + + /** + * Error message from an interaction. + */ + @Deprecated + public Optional error() { + return data().map(Data::error); + } + + public Optional data() { + return Optional.ofNullable(data); + } + + /** + * Returns the exception if an error occurs while deserializing the response body. + */ + public Optional deserializationException() { + return Optional.ofNullable(deserializationException); + } + /** + * Data + * + *

Error getting interaction + */ + public static class Data { + /** + * Error message from an interaction. + */ + @JsonProperty("error") + private Error error; + + @JsonCreator + public Data( + @JsonProperty("error") Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + } + + /** + * Error message from an interaction. + */ + @JsonIgnore + public Error error() { + return error; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public Data withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Data other = (Data) o; + return + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + error); + } + + @Override + public String toString() { + return Utils.toString(Data.class, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Error error; + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public Data build() { + + return new Data( + error); + } + + } + } + +} + 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 new file mode 100644 index 00000000000..207ce285cd8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdServerError.java @@ -0,0 +1,226 @@ +/* +* 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.errors; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Error; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.io.InputStream; +import java.lang.Deprecated; +import java.lang.Exception; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.lang.Throwable; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +@SuppressWarnings({"serial", "all"}) +public class GetInteractionByIdServerError extends GenAiException { + + @Nullable + private final Data data; + + @Nullable + private final Throwable deserializationException; + + public GetInteractionByIdServerError( + int code, + byte[] body, + HttpResponse rawResponse, + @Nullable Data data, + @Nullable Throwable deserializationException) { + super("API error occurred", code, body, rawResponse, null); + this.data = data; + this.deserializationException = deserializationException; + } + + /** + * Parse a response into an instance of GetInteractionByIdServerError. If deserialization of the response body fails, + * the resulting GetInteractionByIdServerError instance will have a null data() value and a non-null deserializationException(). + */ + public static GetInteractionByIdServerError from(HttpResponse response) { + try { + byte[] bytes = Utils.extractByteArrayFromBody(response); + Data data = Utils.mapper().readValue(bytes, Data.class); + return new GetInteractionByIdServerError(response.statusCode(), bytes, response, data, null); + } catch (Exception e) { + return new GetInteractionByIdServerError(response.statusCode(), null, response, null, e); + } + } + + /** + * Parse a response into an instance of GetInteractionByIdServerError asynchronously. If deserialization of the response body fails, + * the resulting GetInteractionByIdServerError instance will have a null data() value and a non-null deserializationException(). + */ + public static CompletableFuture fromAsync(HttpResponse response) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + + try { + return new GetInteractionByIdServerError( + response.statusCode(), + bytes, + response, + Utils.mapper().readValue( + bytes, + new TypeReference() { + }), + null); + } catch (Exception e) { + return new GetInteractionByIdServerError( + response.statusCode(), + bytes, + response, + null, + e); + } + }); + } + + /** + * Error message from an interaction. + */ + @Deprecated + public Optional error() { + return data().map(Data::error); + } + + public Optional data() { + return Optional.ofNullable(data); + } + + /** + * Returns the exception if an error occurs while deserializing the response body. + */ + public Optional deserializationException() { + return Optional.ofNullable(deserializationException); + } + /** + * Data + * + *

Error getting interaction + */ + public static class Data { + /** + * Error message from an interaction. + */ + @JsonProperty("error") + private Error error; + + @JsonCreator + public Data( + @JsonProperty("error") Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + } + + /** + * Error message from an interaction. + */ + @JsonIgnore + public Error error() { + return error; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public Data withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Data other = (Data) o; + return + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + error); + } + + @Override + public String toString() { + return Utils.toString(Data.class, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Error error; + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public Data build() { + + return new Data( + error); + } + + } + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/errors/SDKException.java b/src/main/java/com/google/genai/gaos/models/errors/SDKException.java new file mode 100644 index 00000000000..d709ff7a28b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/SDKException.java @@ -0,0 +1,65 @@ +/* +* 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.errors; + +import jakarta.annotation.Nullable; +import com.google.genai.gaos.utils.Utils; + +import java.io.IOException; +import java.net.http.HttpResponse; +import java.io.InputStream; + +/** + * Thrown by a service call when an error response occurs. Contains details about the response. + */ +@SuppressWarnings({"serial", "all"}) +public class SDKException extends GenAiException { + + public SDKException( + String message, + int code, + @Nullable byte[] body, + HttpResponse rawResponse, + @Nullable Throwable cause) { + super(message, code, body, rawResponse, cause); + } + + public static SDKException from(String message, HttpResponse rawResponse) { + return from(message, rawResponse, null); + } + + public static SDKException from(String message, HttpResponse rawResponse, @Nullable Throwable cause) { + try { + return new SDKException( + 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( + message, rawResponse.statusCode(), null, rawResponse, cause); + } + } + + @SuppressWarnings("unchecked") + @Override + public HttpResponse rawResponse() { + return (HttpResponse) super.rawResponse(); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AgentOption.java b/src/main/java/com/google/genai/gaos/models/interactions/AgentOption.java new file mode 100644 index 00000000000..9de7b4199bf --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AgentOption.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 +* +* 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. + */ +/** + * AgentOption + * + *

The agent to interact with. + */ +@SuppressWarnings("all") +public class AgentOption { + + public static final AgentOption DEEP_RESEARCH_PRO_PREVIEW122025 = new AgentOption("deep-research-pro-preview-12-2025"); + public static final AgentOption DEEP_RESEARCH_PREVIEW042026 = new AgentOption("deep-research-preview-04-2026"); + public static final AgentOption DEEP_RESEARCH_MAX_PREVIEW042026 = new AgentOption("deep-research-max-preview-04-2026"); + public static final AgentOption ANTIGRAVITY_PREVIEW052026 = new AgentOption("antigravity-preview-05-2026"); + + // 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 AgentOption(String value) { + this.value = value; + } + + /** + * Returns a AgentOption 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 AgentOption + */ + @JsonCreator + public static AgentOption of(String value) { + synchronized (AgentOption.class) { + return values.computeIfAbsent(value, v -> new AgentOption(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; + AgentOption other = (AgentOption) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "AgentOption [value=" + value + "]"; + } + + // return an array just like an enum + public static AgentOption[] values() { + synchronized (AgentOption.class) { + return values.values().toArray(new AgentOption[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("deep-research-pro-preview-12-2025", DEEP_RESEARCH_PRO_PREVIEW122025); + map.put("deep-research-preview-04-2026", DEEP_RESEARCH_PREVIEW042026); + map.put("deep-research-max-preview-04-2026", DEEP_RESEARCH_MAX_PREVIEW042026); + map.put("antigravity-preview-05-2026", ANTIGRAVITY_PREVIEW052026); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("deep-research-pro-preview-12-2025", AgentOptionEnum.DEEP_RESEARCH_PRO_PREVIEW122025); + map.put("deep-research-preview-04-2026", AgentOptionEnum.DEEP_RESEARCH_PREVIEW042026); + map.put("deep-research-max-preview-04-2026", AgentOptionEnum.DEEP_RESEARCH_MAX_PREVIEW042026); + map.put("antigravity-preview-05-2026", AgentOptionEnum.ANTIGRAVITY_PREVIEW052026); + return map; + } + + + public enum AgentOptionEnum { + + DEEP_RESEARCH_PRO_PREVIEW122025("deep-research-pro-preview-12-2025"), + DEEP_RESEARCH_PREVIEW042026("deep-research-preview-04-2026"), + DEEP_RESEARCH_MAX_PREVIEW042026("deep-research-max-preview-04-2026"), + ANTIGRAVITY_PREVIEW052026("antigravity-preview-05-2026"),; + + private final String value; + + private AgentOptionEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AllowedTools.java b/src/main/java/com/google/genai/gaos/models/interactions/AllowedTools.java new file mode 100644 index 00000000000..333d11ecf8d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AllowedTools.java @@ -0,0 +1,196 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * AllowedTools + * + *

The configuration for allowed tools. + */ +@SuppressWarnings("all") +public class AllowedTools { + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mode") + private Optional mode; + + /** + * The names of the allowed tools. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("tools") + private Optional> tools; + + @JsonCreator + public AllowedTools( + @JsonProperty("mode") Optional mode, + @JsonProperty("tools") Optional> tools) { + Utils.checkNotNull(mode, "mode"); + Utils.checkNotNull(tools, "tools"); + this.mode = mode; + this.tools = tools; + } + + public AllowedTools() { + this(Optional.empty(), Optional.empty()); + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mode() { + return (Optional) mode; + } + + /** + * The names of the allowed tools. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> tools() { + return (Optional>) tools; + } + + public static Builder builder() { + return new Builder(); + } + + + public AllowedTools withMode(ToolChoiceType mode) { + Utils.checkNotNull(mode, "mode"); + this.mode = Optional.ofNullable(mode); + return this; + } + + + public AllowedTools withMode(Optional mode) { + Utils.checkNotNull(mode, "mode"); + this.mode = mode; + return this; + } + + /** + * The names of the allowed tools. + */ + public AllowedTools withTools(List tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = Optional.ofNullable(tools); + return this; + } + + + /** + * The names of the allowed tools. + */ + public AllowedTools withTools(Optional> tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = tools; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AllowedTools other = (AllowedTools) o; + return + Utils.enhancedDeepEquals(this.mode, other.mode) && + Utils.enhancedDeepEquals(this.tools, other.tools); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + mode, tools); + } + + @Override + public String toString() { + return Utils.toString(AllowedTools.class, + "mode", mode, + "tools", tools); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional mode = Optional.empty(); + + private Optional> tools = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder mode(ToolChoiceType mode) { + Utils.checkNotNull(mode, "mode"); + this.mode = Optional.ofNullable(mode); + return this; + } + + public Builder mode(Optional mode) { + Utils.checkNotNull(mode, "mode"); + this.mode = mode; + return this; + } + + + /** + * The names of the allowed tools. + */ + public Builder tools(List tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = Optional.ofNullable(tools); + return this; + } + + /** + * The names of the allowed tools. + */ + public Builder tools(Optional> tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = tools; + return this; + } + + public AllowedTools build() { + + return new AllowedTools( + mode, tools); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Allowlist.java b/src/main/java/com/google/genai/gaos/models/interactions/Allowlist.java new file mode 100644 index 00000000000..85785323824 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Allowlist.java @@ -0,0 +1,159 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * Allowlist + * + *

Outbound networking configuration for the sandbox. When specified, restricts which external domains + * the sandbox can reach. Omit entirely to allow all outbound traffic with no header injection. + */ +@SuppressWarnings("all") +public class Allowlist { + /** + * List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': + * '*'}] to allow all domains while still injecting headers on specific ones. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("allowlist") + private Optional> allowlist; + + @JsonCreator + public Allowlist( + @JsonProperty("allowlist") Optional> allowlist) { + Utils.checkNotNull(allowlist, "allowlist"); + this.allowlist = allowlist; + } + + public Allowlist() { + this(Optional.empty()); + } + + /** + * List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': + * '*'}] to allow all domains while still injecting headers on specific ones. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> allowlist() { + return (Optional>) allowlist; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': + * '*'}] to allow all domains while still injecting headers on specific ones. + */ + public Allowlist withAllowlist(List allowlist) { + Utils.checkNotNull(allowlist, "allowlist"); + this.allowlist = Optional.ofNullable(allowlist); + return this; + } + + + /** + * List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': + * '*'}] to allow all domains while still injecting headers on specific ones. + */ + public Allowlist withAllowlist(Optional> allowlist) { + Utils.checkNotNull(allowlist, "allowlist"); + this.allowlist = allowlist; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Allowlist other = (Allowlist) o; + return + Utils.enhancedDeepEquals(this.allowlist, other.allowlist); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + allowlist); + } + + @Override + public String toString() { + return Utils.toString(Allowlist.class, + "allowlist", allowlist); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> allowlist = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': + * '*'}] to allow all domains while still injecting headers on specific ones. + */ + public Builder allowlist(List allowlist) { + Utils.checkNotNull(allowlist, "allowlist"); + this.allowlist = Optional.ofNullable(allowlist); + return this; + } + + /** + * List of allowed outbound domains. Only requests to listed domains are permitted. Use [{'domain': + * '*'}] to allow all domains while still injecting headers on specific ones. + */ + public Builder allowlist(Optional> allowlist) { + Utils.checkNotNull(allowlist, "allowlist"); + this.allowlist = allowlist; + return this; + } + + public Allowlist build() { + + return new Allowlist( + allowlist); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AllowlistEntry.java b/src/main/java/com/google/genai/gaos/models/interactions/AllowlistEntry.java new file mode 100644 index 00000000000..9fcf7e2fdac --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AllowlistEntry.java @@ -0,0 +1,208 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * AllowlistEntry + * + *

A single domain allowlist rule with optional header injection. + */ +@SuppressWarnings("all") +public class AllowlistEntry { + /** + * Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). + * + *

Use '*' to allow all domains. + */ + @JsonProperty("domain") + private String domain; + + /** + * Headers to inject on all outbound requests matching this domain. Each entry is a flat {header_name: + * header_value} object. The egress proxy injects these automatically. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("transform") + private Optional>> transform; + + @JsonCreator + public AllowlistEntry( + @JsonProperty("domain") String domain, + @JsonProperty("transform") Optional>> transform) { + Utils.checkNotNull(domain, "domain"); + Utils.checkNotNull(transform, "transform"); + this.domain = domain; + this.transform = transform; + } + + public AllowlistEntry( + String domain) { + this(domain, Optional.empty()); + } + + /** + * Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). + * + *

Use '*' to allow all domains. + */ + @JsonIgnore + public String domain() { + return domain; + } + + /** + * Headers to inject on all outbound requests matching this domain. Each entry is a flat {header_name: + * header_value} object. The egress proxy injects these automatically. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional>> transform() { + return (Optional>>) transform; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). + * + *

Use '*' to allow all domains. + */ + public AllowlistEntry withDomain(String domain) { + Utils.checkNotNull(domain, "domain"); + this.domain = domain; + return this; + } + + /** + * Headers to inject on all outbound requests matching this domain. Each entry is a flat {header_name: + * header_value} object. The egress proxy injects these automatically. + */ + public AllowlistEntry withTransform(List> transform) { + Utils.checkNotNull(transform, "transform"); + this.transform = Optional.ofNullable(transform); + return this; + } + + + /** + * Headers to inject on all outbound requests matching this domain. Each entry is a flat {header_name: + * header_value} object. The egress proxy injects these automatically. + */ + public AllowlistEntry withTransform(Optional>> transform) { + Utils.checkNotNull(transform, "transform"); + this.transform = transform; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AllowlistEntry other = (AllowlistEntry) o; + return + Utils.enhancedDeepEquals(this.domain, other.domain) && + Utils.enhancedDeepEquals(this.transform, other.transform); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + domain, transform); + } + + @Override + public String toString() { + return Utils.toString(AllowlistEntry.class, + "domain", domain, + "transform", transform); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String domain; + + private Optional>> transform = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Domain to allow outbound requests to. Supports wildcards (e.g. '*.googleapis.com'). + * + *

Use '*' to allow all domains. + */ + public Builder domain(String domain) { + Utils.checkNotNull(domain, "domain"); + this.domain = domain; + return this; + } + + + /** + * Headers to inject on all outbound requests matching this domain. Each entry is a flat {header_name: + * header_value} object. The egress proxy injects these automatically. + */ + public Builder transform(List> transform) { + Utils.checkNotNull(transform, "transform"); + this.transform = Optional.ofNullable(transform); + return this; + } + + /** + * Headers to inject on all outbound requests matching this domain. Each entry is a flat {header_name: + * header_value} object. The egress proxy injects these automatically. + */ + public Builder transform(Optional>> transform) { + Utils.checkNotNull(transform, "transform"); + this.transform = transform; + return this; + } + + public AllowlistEntry build() { + + return new AllowlistEntry( + domain, transform); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Annotation.java b/src/main/java/com/google/genai/gaos/models/interactions/Annotation.java new file mode 100644 index 00000000000..c52e80f8203 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Annotation.java @@ -0,0 +1,123 @@ +/* +* 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.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; + +/** + * Annotation + * + *

Citation information for model-generated content. + */ +@JsonDeserialize(using = Annotation._Deserializer.class) +@SuppressWarnings("all") +public class Annotation { + + @JsonValue + private final TypedObject value; + + private Annotation(TypedObject value) { + this.value = value; + } + + public static Annotation of(URLCitation value) { + Utils.checkNotNull(value, "value"); + return new Annotation(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Annotation of(FileCitation value) { + Utils.checkNotNull(value, "value"); + return new Annotation(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Annotation of(PlaceCitation value) { + Utils.checkNotNull(value, "value"); + return new Annotation(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.URLCitation}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FileCitation}
  • + *
  • {@code com.google.genai.gaos.models.interactions.PlaceCitation}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Annotation other = (Annotation) 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(Annotation.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(Annotation.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Arguments.java b/src/main/java/com/google/genai/gaos/models/interactions/Arguments.java new file mode 100644 index 00000000000..5e04e16e834 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Arguments.java @@ -0,0 +1,152 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * Arguments + * + *

The arguments to pass to the URL context. + */ +@SuppressWarnings("all") +public class Arguments { + /** + * The URLs to fetch. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("urls") + private Optional> urls; + + @JsonCreator + public Arguments( + @JsonProperty("urls") Optional> urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = urls; + } + + public Arguments() { + this(Optional.empty()); + } + + /** + * The URLs to fetch. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> urls() { + return (Optional>) urls; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The URLs to fetch. + */ + public Arguments withUrls(List urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = Optional.ofNullable(urls); + return this; + } + + + /** + * The URLs to fetch. + */ + public Arguments withUrls(Optional> urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = urls; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Arguments other = (Arguments) o; + return + Utils.enhancedDeepEquals(this.urls, other.urls); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + urls); + } + + @Override + public String toString() { + return Utils.toString(Arguments.class, + "urls", urls); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> urls = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The URLs to fetch. + */ + public Builder urls(List urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = Optional.ofNullable(urls); + return this; + } + + /** + * The URLs to fetch. + */ + public Builder urls(Optional> urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = urls; + return this; + } + + public Arguments build() { + + return new Arguments( + urls); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ArgumentsDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/ArgumentsDelta.java new file mode 100644 index 00000000000..939862865cb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ArgumentsDelta.java @@ -0,0 +1,148 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ArgumentsDelta { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("arguments") + private Optional arguments; + + @JsonCreator + public ArgumentsDelta( + @JsonProperty("arguments") Optional arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.arguments = arguments; + } + + public ArgumentsDelta() { + this(Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public Optional arguments() { + return arguments; + } + + public static Builder builder() { + return new Builder(); + } + + + public ArgumentsDelta withArguments(String arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = Optional.ofNullable(arguments); + return this; + } + + + public ArgumentsDelta withArguments(Optional arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArgumentsDelta other = (ArgumentsDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.arguments, other.arguments); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, arguments); + } + + @Override + public String toString() { + return Utils.toString(ArgumentsDelta.class, + "type", type, + "arguments", arguments); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional arguments = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder arguments(String arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = Optional.ofNullable(arguments); + return this; + } + + public Builder arguments(Optional arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + public ArgumentsDelta build() { + + return new ArgumentsDelta( + arguments); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"arguments_delta\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AudioContent.java b/src/main/java/com/google/genai/gaos/models/interactions/AudioContent.java new file mode 100644 index 00000000000..3904bb66421 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AudioContent.java @@ -0,0 +1,415 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * AudioContent + * + *

An audio content block. + */ +@SuppressWarnings("all") +public class AudioContent { + + @JsonProperty("type") + private String type; + + /** + * The audio content. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("data") + private Optional data; + + /** + * The URI of the audio. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + /** + * The mime type of the audio. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + /** + * The number of audio channels. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("channels") + private Optional channels; + + /** + * The sample rate of the audio. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("sample_rate") + private Optional sampleRate; + + @JsonCreator + public AudioContent( + @JsonProperty("data") Optional data, + @JsonProperty("uri") Optional uri, + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("channels") Optional channels, + @JsonProperty("sample_rate") Optional sampleRate) { + Utils.checkNotNull(data, "data"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(channels, "channels"); + Utils.checkNotNull(sampleRate, "sampleRate"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.data = data; + this.uri = uri; + this.mimeType = mimeType; + this.channels = channels; + this.sampleRate = sampleRate; + } + + public AudioContent() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The audio content. + */ + @JsonIgnore + public Optional data() { + return data; + } + + /** + * The URI of the audio. + */ + @JsonIgnore + public Optional uri() { + return uri; + } + + /** + * The mime type of the audio. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + /** + * The number of audio channels. + */ + @JsonIgnore + public Optional channels() { + return channels; + } + + /** + * The sample rate of the audio. + */ + @JsonIgnore + public Optional sampleRate() { + return sampleRate; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The audio content. + */ + public AudioContent withData(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + + /** + * The audio content. + */ + public AudioContent withData(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + /** + * The URI of the audio. + */ + public AudioContent withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + /** + * The URI of the audio. + */ + public AudioContent withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + /** + * The mime type of the audio. + */ + public AudioContent withMimeType(AudioContentMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + /** + * The mime type of the audio. + */ + public AudioContent withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + /** + * The number of audio channels. + */ + public AudioContent withChannels(int channels) { + Utils.checkNotNull(channels, "channels"); + this.channels = Optional.ofNullable(channels); + return this; + } + + + /** + * The number of audio channels. + */ + public AudioContent withChannels(Optional channels) { + Utils.checkNotNull(channels, "channels"); + this.channels = channels; + return this; + } + + /** + * The sample rate of the audio. + */ + public AudioContent withSampleRate(int sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = Optional.ofNullable(sampleRate); + return this; + } + + + /** + * The sample rate of the audio. + */ + public AudioContent withSampleRate(Optional sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = sampleRate; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AudioContent other = (AudioContent) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.channels, other.channels) && + Utils.enhancedDeepEquals(this.sampleRate, other.sampleRate); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, data, uri, + mimeType, channels, sampleRate); + } + + @Override + public String toString() { + return Utils.toString(AudioContent.class, + "type", type, + "data", data, + "uri", uri, + "mimeType", mimeType, + "channels", channels, + "sampleRate", sampleRate); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional data = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + private Optional channels = Optional.empty(); + + private Optional sampleRate = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The audio content. + */ + public Builder data(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + /** + * The audio content. + */ + public Builder data(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + + /** + * The URI of the audio. + */ + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + /** + * The URI of the audio. + */ + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + /** + * The mime type of the audio. + */ + public Builder mimeType(AudioContentMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + /** + * The mime type of the audio. + */ + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + /** + * The number of audio channels. + */ + public Builder channels(int channels) { + Utils.checkNotNull(channels, "channels"); + this.channels = Optional.ofNullable(channels); + return this; + } + + /** + * The number of audio channels. + */ + public Builder channels(Optional channels) { + Utils.checkNotNull(channels, "channels"); + this.channels = channels; + return this; + } + + + /** + * The sample rate of the audio. + */ + public Builder sampleRate(int sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = Optional.ofNullable(sampleRate); + return this; + } + + /** + * The sample rate of the audio. + */ + public Builder sampleRate(Optional sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = sampleRate; + return this; + } + + public AudioContent build() { + + return new AudioContent( + data, uri, mimeType, + channels, sampleRate); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"audio\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AudioContentMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/AudioContentMimeType.java new file mode 100644 index 00000000000..c9c429353c1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AudioContentMimeType.java @@ -0,0 +1,67 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * AudioContentMimeType + * + *

The mime type of the audio. + */ +@SuppressWarnings("all") +public enum AudioContentMimeType { + AUDIO_WAV("audio/wav"), + AUDIO_MP3("audio/mp3"), + AUDIO_AIFF("audio/aiff"), + AUDIO_AAC("audio/aac"), + AUDIO_OGG("audio/ogg"), + AUDIO_FLAC("audio/flac"), + AUDIO_MPEG("audio/mpeg"), + AUDIO_M4A("audio/m4a"), + AUDIO_L16("audio/l16"), + AUDIO_OPUS("audio/opus"), + AUDIO_ALAW("audio/alaw"), + AUDIO_MULAW("audio/mulaw"); + + @JsonValue + private final String value; + + AudioContentMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (AudioContentMimeType o: AudioContentMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AudioDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/AudioDelta.java new file mode 100644 index 00000000000..8b4f184c9cb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AudioDelta.java @@ -0,0 +1,441 @@ +/* +* 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.JsonIgnore; +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 java.lang.Deprecated; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class AudioDelta { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("data") + private Optional data; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + /** + * Deprecated. Use sample_rate instead. The value is ignored. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("rate") + @Deprecated + private Optional rate; + + /** + * The sample rate of the audio. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("sample_rate") + private Optional sampleRate; + + /** + * The number of audio channels. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("channels") + private Optional channels; + + @JsonCreator + public AudioDelta( + @JsonProperty("data") Optional data, + @JsonProperty("uri") Optional uri, + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("rate") Optional rate, + @JsonProperty("sample_rate") Optional sampleRate, + @JsonProperty("channels") Optional channels) { + Utils.checkNotNull(data, "data"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(rate, "rate"); + Utils.checkNotNull(sampleRate, "sampleRate"); + Utils.checkNotNull(channels, "channels"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.data = data; + this.uri = uri; + this.mimeType = mimeType; + this.rate = rate; + this.sampleRate = sampleRate; + this.channels = channels; + } + + public AudioDelta() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public Optional data() { + return data; + } + + @JsonIgnore + public Optional uri() { + return uri; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + /** + * Deprecated. Use sample_rate instead. The value is ignored. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + @JsonIgnore + public Optional rate() { + return rate; + } + + /** + * The sample rate of the audio. + */ + @JsonIgnore + public Optional sampleRate() { + return sampleRate; + } + + /** + * The number of audio channels. + */ + @JsonIgnore + public Optional channels() { + return channels; + } + + public static Builder builder() { + return new Builder(); + } + + + public AudioDelta withData(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + + public AudioDelta withData(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + public AudioDelta withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + public AudioDelta withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + public AudioDelta withMimeType(AudioDeltaMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + public AudioDelta withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + /** + * Deprecated. Use sample_rate instead. The value is ignored. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public AudioDelta withRate(int rate) { + Utils.checkNotNull(rate, "rate"); + this.rate = Optional.ofNullable(rate); + return this; + } + + + /** + * Deprecated. Use sample_rate instead. The value is ignored. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public AudioDelta withRate(Optional rate) { + Utils.checkNotNull(rate, "rate"); + this.rate = rate; + return this; + } + + /** + * The sample rate of the audio. + */ + public AudioDelta withSampleRate(int sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = Optional.ofNullable(sampleRate); + return this; + } + + + /** + * The sample rate of the audio. + */ + public AudioDelta withSampleRate(Optional sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = sampleRate; + return this; + } + + /** + * The number of audio channels. + */ + public AudioDelta withChannels(int channels) { + Utils.checkNotNull(channels, "channels"); + this.channels = Optional.ofNullable(channels); + return this; + } + + + /** + * The number of audio channels. + */ + public AudioDelta withChannels(Optional channels) { + Utils.checkNotNull(channels, "channels"); + this.channels = channels; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AudioDelta other = (AudioDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.rate, other.rate) && + Utils.enhancedDeepEquals(this.sampleRate, other.sampleRate) && + Utils.enhancedDeepEquals(this.channels, other.channels); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, data, uri, + mimeType, rate, sampleRate, + channels); + } + + @Override + public String toString() { + return Utils.toString(AudioDelta.class, + "type", type, + "data", data, + "uri", uri, + "mimeType", mimeType, + "rate", rate, + "sampleRate", sampleRate, + "channels", channels); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional data = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + @Deprecated + private Optional rate = Optional.empty(); + + private Optional sampleRate = Optional.empty(); + + private Optional channels = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder data(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + public Builder data(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + public Builder mimeType(AudioDeltaMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + /** + * Deprecated. Use sample_rate instead. The value is ignored. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder rate(int rate) { + Utils.checkNotNull(rate, "rate"); + this.rate = Optional.ofNullable(rate); + return this; + } + + /** + * Deprecated. Use sample_rate instead. The value is ignored. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder rate(Optional rate) { + Utils.checkNotNull(rate, "rate"); + this.rate = rate; + return this; + } + + + /** + * The sample rate of the audio. + */ + public Builder sampleRate(int sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = Optional.ofNullable(sampleRate); + return this; + } + + /** + * The sample rate of the audio. + */ + public Builder sampleRate(Optional sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = sampleRate; + return this; + } + + + /** + * The number of audio channels. + */ + public Builder channels(int channels) { + Utils.checkNotNull(channels, "channels"); + this.channels = Optional.ofNullable(channels); + return this; + } + + /** + * The number of audio channels. + */ + public Builder channels(Optional channels) { + Utils.checkNotNull(channels, "channels"); + this.channels = channels; + return this; + } + + public AudioDelta build() { + + return new AudioDelta( + data, uri, mimeType, + rate, sampleRate, channels); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"audio\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AudioDeltaMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/AudioDeltaMimeType.java new file mode 100644 index 00000000000..3e65191a5dc --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AudioDeltaMimeType.java @@ -0,0 +1,62 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum AudioDeltaMimeType { + AUDIO_WAV("audio/wav"), + AUDIO_MP3("audio/mp3"), + AUDIO_AIFF("audio/aiff"), + AUDIO_AAC("audio/aac"), + AUDIO_OGG("audio/ogg"), + AUDIO_FLAC("audio/flac"), + AUDIO_MPEG("audio/mpeg"), + AUDIO_M4A("audio/m4a"), + AUDIO_L16("audio/l16"), + AUDIO_OPUS("audio/opus"), + AUDIO_ALAW("audio/alaw"), + AUDIO_MULAW("audio/mulaw"); + + @JsonValue + private final String value; + + AudioDeltaMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (AudioDeltaMimeType o: AudioDeltaMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormat.java b/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormat.java new file mode 100644 index 00000000000..6f9d8f7c71b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormat.java @@ -0,0 +1,362 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * AudioResponseFormat + * + *

Configuration for audio output format. + */ +@SuppressWarnings("all") +public class AudioResponseFormat { + + @JsonProperty("type") + private String type; + + /** + * The MIME type of the audio output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + /** + * The delivery mode for the audio output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("delivery") + private Optional delivery; + + /** + * Sample rate in Hz. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("sample_rate") + private Optional sampleRate; + + /** + * Bit rate in bits per second (bps). Only applicable for compressed formats + * (MP3, Opus). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("bit_rate") + private Optional bitRate; + + @JsonCreator + public AudioResponseFormat( + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("delivery") Optional delivery, + @JsonProperty("sample_rate") Optional sampleRate, + @JsonProperty("bit_rate") Optional bitRate) { + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(delivery, "delivery"); + Utils.checkNotNull(sampleRate, "sampleRate"); + Utils.checkNotNull(bitRate, "bitRate"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.mimeType = mimeType; + this.delivery = delivery; + this.sampleRate = sampleRate; + this.bitRate = bitRate; + } + + public AudioResponseFormat() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The MIME type of the audio output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + /** + * The delivery mode for the audio output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional delivery() { + return (Optional) delivery; + } + + /** + * Sample rate in Hz. + */ + @JsonIgnore + public Optional sampleRate() { + return sampleRate; + } + + /** + * Bit rate in bits per second (bps). Only applicable for compressed formats + * (MP3, Opus). + */ + @JsonIgnore + public Optional bitRate() { + return bitRate; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The MIME type of the audio output. + */ + public AudioResponseFormat withMimeType(AudioResponseFormatMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + /** + * The MIME type of the audio output. + */ + public AudioResponseFormat withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + /** + * The delivery mode for the audio output. + */ + public AudioResponseFormat withDelivery(AudioResponseFormatDelivery delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = Optional.ofNullable(delivery); + return this; + } + + + /** + * The delivery mode for the audio output. + */ + public AudioResponseFormat withDelivery(Optional delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = delivery; + return this; + } + + /** + * Sample rate in Hz. + */ + public AudioResponseFormat withSampleRate(int sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = Optional.ofNullable(sampleRate); + return this; + } + + + /** + * Sample rate in Hz. + */ + public AudioResponseFormat withSampleRate(Optional sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = sampleRate; + return this; + } + + /** + * Bit rate in bits per second (bps). Only applicable for compressed formats + * (MP3, Opus). + */ + public AudioResponseFormat withBitRate(int bitRate) { + Utils.checkNotNull(bitRate, "bitRate"); + this.bitRate = Optional.ofNullable(bitRate); + return this; + } + + + /** + * Bit rate in bits per second (bps). Only applicable for compressed formats + * (MP3, Opus). + */ + public AudioResponseFormat withBitRate(Optional bitRate) { + Utils.checkNotNull(bitRate, "bitRate"); + this.bitRate = bitRate; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AudioResponseFormat other = (AudioResponseFormat) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.delivery, other.delivery) && + Utils.enhancedDeepEquals(this.sampleRate, other.sampleRate) && + Utils.enhancedDeepEquals(this.bitRate, other.bitRate); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, mimeType, delivery, + sampleRate, bitRate); + } + + @Override + public String toString() { + return Utils.toString(AudioResponseFormat.class, + "type", type, + "mimeType", mimeType, + "delivery", delivery, + "sampleRate", sampleRate, + "bitRate", bitRate); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional mimeType = Optional.empty(); + + private Optional delivery = Optional.empty(); + + private Optional sampleRate = Optional.empty(); + + private Optional bitRate = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The MIME type of the audio output. + */ + public Builder mimeType(AudioResponseFormatMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + /** + * The MIME type of the audio output. + */ + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + /** + * The delivery mode for the audio output. + */ + public Builder delivery(AudioResponseFormatDelivery delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = Optional.ofNullable(delivery); + return this; + } + + /** + * The delivery mode for the audio output. + */ + public Builder delivery(Optional delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = delivery; + return this; + } + + + /** + * Sample rate in Hz. + */ + public Builder sampleRate(int sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = Optional.ofNullable(sampleRate); + return this; + } + + /** + * Sample rate in Hz. + */ + public Builder sampleRate(Optional sampleRate) { + Utils.checkNotNull(sampleRate, "sampleRate"); + this.sampleRate = sampleRate; + return this; + } + + + /** + * Bit rate in bits per second (bps). Only applicable for compressed formats + * (MP3, Opus). + */ + public Builder bitRate(int bitRate) { + Utils.checkNotNull(bitRate, "bitRate"); + this.bitRate = Optional.ofNullable(bitRate); + return this; + } + + /** + * Bit rate in bits per second (bps). Only applicable for compressed formats + * (MP3, Opus). + */ + public Builder bitRate(Optional bitRate) { + Utils.checkNotNull(bitRate, "bitRate"); + this.bitRate = bitRate; + return this; + } + + public AudioResponseFormat build() { + + return new AudioResponseFormat( + mimeType, delivery, sampleRate, + bitRate); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"audio\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormatDelivery.java b/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormatDelivery.java new file mode 100644 index 00000000000..3164ca7c062 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormatDelivery.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * AudioResponseFormatDelivery + * + *

The delivery mode for the audio output. + */ +@SuppressWarnings("all") +public enum AudioResponseFormatDelivery { + INLINE("inline"), + URI("uri"); + + @JsonValue + private final String value; + + AudioResponseFormatDelivery(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (AudioResponseFormatDelivery o: AudioResponseFormatDelivery.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormatMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormatMimeType.java new file mode 100644 index 00000000000..126bf997fde --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/AudioResponseFormatMimeType.java @@ -0,0 +1,61 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * AudioResponseFormatMimeType + * + *

The MIME type of the audio output. + */ +@SuppressWarnings("all") +public enum AudioResponseFormatMimeType { + AUDIO_MP3("audio/mp3"), + AUDIO_OGG_OPUS("audio/ogg_opus"), + AUDIO_L16("audio/l16"), + AUDIO_WAV("audio/wav"), + AUDIO_ALAW("audio/alaw"), + AUDIO_MULAW("audio/mulaw"); + + @JsonValue + private final String value; + + AudioResponseFormatMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (AudioResponseFormatMimeType o: AudioResponseFormatMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CodeExecution.java b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecution.java new file mode 100644 index 00000000000..c38b48e02f1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecution.java @@ -0,0 +1,99 @@ +/* +* 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.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.utils.LazySingletonValue; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + +/** + * CodeExecution + * + *

A tool that can be used by the model to execute code. + */ +@SuppressWarnings("all") +public class CodeExecution { + + @JsonProperty("type") + private String type; + + @JsonCreator + public CodeExecution() { + this.type = Builder._SINGLETON_VALUE_Type.value(); + } + + public String type() { + return Utils.discriminatorToString(type); + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CodeExecution other = (CodeExecution) o; + return + Utils.enhancedDeepEquals(this.type, other.type); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type); + } + + @Override + public String toString() { + return Utils.toString(CodeExecution.class, + "type", type); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public CodeExecution build() { + return new CodeExecution( + ); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"code_execution\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallArguments.java b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallArguments.java new file mode 100644 index 00000000000..3e3256c4c2c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallArguments.java @@ -0,0 +1,211 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * CodeExecutionCallArguments + * + *

The arguments to pass to the code execution. + */ +@SuppressWarnings("all") +public class CodeExecutionCallArguments { + /** + * Programming language of the `code`. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("language") + private Optional language; + + /** + * The code to be executed. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("code") + private Optional code; + + @JsonCreator + public CodeExecutionCallArguments( + @JsonProperty("language") Optional language, + @JsonProperty("code") Optional code) { + Utils.checkNotNull(language, "language"); + Utils.checkNotNull(code, "code"); + this.language = language; + this.code = code; + } + + public CodeExecutionCallArguments() { + this(Optional.empty(), Optional.empty()); + } + + /** + * Programming language of the `code`. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional language() { + return (Optional) language; + } + + /** + * The code to be executed. + */ + @JsonIgnore + public Optional code() { + return code; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Programming language of the `code`. + */ + public CodeExecutionCallArguments withLanguage(Language language) { + Utils.checkNotNull(language, "language"); + this.language = Optional.ofNullable(language); + return this; + } + + + /** + * Programming language of the `code`. + */ + public CodeExecutionCallArguments withLanguage(Optional language) { + Utils.checkNotNull(language, "language"); + this.language = language; + return this; + } + + /** + * The code to be executed. + */ + public CodeExecutionCallArguments withCode(String code) { + Utils.checkNotNull(code, "code"); + this.code = Optional.ofNullable(code); + return this; + } + + + /** + * The code to be executed. + */ + public CodeExecutionCallArguments withCode(Optional code) { + Utils.checkNotNull(code, "code"); + this.code = code; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CodeExecutionCallArguments other = (CodeExecutionCallArguments) o; + return + Utils.enhancedDeepEquals(this.language, other.language) && + Utils.enhancedDeepEquals(this.code, other.code); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + language, code); + } + + @Override + public String toString() { + return Utils.toString(CodeExecutionCallArguments.class, + "language", language, + "code", code); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional language = Optional.empty(); + + private Optional code = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Programming language of the `code`. + */ + public Builder language(Language language) { + Utils.checkNotNull(language, "language"); + this.language = Optional.ofNullable(language); + return this; + } + + /** + * Programming language of the `code`. + */ + public Builder language(Optional language) { + Utils.checkNotNull(language, "language"); + this.language = language; + return this; + } + + + /** + * The code to be executed. + */ + public Builder code(String code) { + Utils.checkNotNull(code, "code"); + this.code = Optional.ofNullable(code); + return this; + } + + /** + * The code to be executed. + */ + public Builder code(Optional code) { + Utils.checkNotNull(code, "code"); + this.code = code; + return this; + } + + public CodeExecutionCallArguments build() { + + return new CodeExecutionCallArguments( + language, code); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallDelta.java new file mode 100644 index 00000000000..dbbace8af1e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallDelta.java @@ -0,0 +1,206 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CodeExecutionCallDelta { + + @JsonProperty("type") + private String type; + + /** + * The arguments to pass to the code execution. + */ + @JsonProperty("arguments") + private CodeExecutionCallArguments arguments; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public CodeExecutionCallDelta( + @JsonProperty("arguments") CodeExecutionCallArguments arguments, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.arguments = arguments; + this.signature = signature; + } + + public CodeExecutionCallDelta( + CodeExecutionCallArguments arguments) { + this(arguments, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The arguments to pass to the code execution. + */ + @JsonIgnore + public CodeExecutionCallArguments arguments() { + return arguments; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The arguments to pass to the code execution. + */ + public CodeExecutionCallDelta withArguments(CodeExecutionCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * A signature hash for backend validation. + */ + public CodeExecutionCallDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public CodeExecutionCallDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CodeExecutionCallDelta other = (CodeExecutionCallDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, arguments, signature); + } + + @Override + public String toString() { + return Utils.toString(CodeExecutionCallDelta.class, + "type", type, + "arguments", arguments, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private CodeExecutionCallArguments arguments; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The arguments to pass to the code execution. + */ + public Builder arguments(CodeExecutionCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public CodeExecutionCallDelta build() { + + return new CodeExecutionCallDelta( + arguments, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"code_execution_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallStep.java b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallStep.java new file mode 100644 index 00000000000..1013a27abdc --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionCallStep.java @@ -0,0 +1,252 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * CodeExecutionCallStep + * + *

Code execution call step. + */ +@SuppressWarnings("all") +public class CodeExecutionCallStep { + + @JsonProperty("type") + private String type; + + /** + * The arguments to pass to the code execution. + */ + @JsonProperty("arguments") + private CodeExecutionCallArguments arguments; + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonProperty("id") + private String id; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public CodeExecutionCallStep( + @JsonProperty("arguments") CodeExecutionCallArguments arguments, + @JsonProperty("id") String id, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.arguments = arguments; + this.id = id; + this.signature = signature; + } + + public CodeExecutionCallStep( + CodeExecutionCallArguments arguments, + String id) { + this(arguments, id, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The arguments to pass to the code execution. + */ + @JsonIgnore + public CodeExecutionCallArguments arguments() { + return arguments; + } + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The arguments to pass to the code execution. + */ + public CodeExecutionCallStep withArguments(CodeExecutionCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * Required. A unique ID for this specific tool call. + */ + public CodeExecutionCallStep withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * A signature hash for backend validation. + */ + public CodeExecutionCallStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public CodeExecutionCallStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CodeExecutionCallStep other = (CodeExecutionCallStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, arguments, id, + signature); + } + + @Override + public String toString() { + return Utils.toString(CodeExecutionCallStep.class, + "type", type, + "arguments", arguments, + "id", id, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private CodeExecutionCallArguments arguments; + + private String id; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The arguments to pass to the code execution. + */ + public Builder arguments(CodeExecutionCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public CodeExecutionCallStep build() { + + return new CodeExecutionCallStep( + arguments, id, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"code_execution_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionResultDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionResultDelta.java new file mode 100644 index 00000000000..33dea5ffc1a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionResultDelta.java @@ -0,0 +1,240 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CodeExecutionResultDelta { + + @JsonProperty("type") + private String type; + + + @JsonProperty("result") + private String result; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("is_error") + private Optional isError; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public CodeExecutionResultDelta( + @JsonProperty("result") String result, + @JsonProperty("is_error") Optional isError, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(isError, "isError"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.isError = isError; + this.signature = signature; + } + + public CodeExecutionResultDelta( + String result) { + this(result, Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public String result() { + return result; + } + + @JsonIgnore + public Optional isError() { + return isError; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + public CodeExecutionResultDelta withResult(String result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + public CodeExecutionResultDelta withIsError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + + public CodeExecutionResultDelta withIsError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + /** + * A signature hash for backend validation. + */ + public CodeExecutionResultDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public CodeExecutionResultDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CodeExecutionResultDelta other = (CodeExecutionResultDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.isError, other.isError) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, isError, + signature); + } + + @Override + public String toString() { + return Utils.toString(CodeExecutionResultDelta.class, + "type", type, + "result", result, + "isError", isError, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String result; + + private Optional isError = Optional.empty(); + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder result(String result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + public Builder isError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + public Builder isError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public CodeExecutionResultDelta build() { + + return new CodeExecutionResultDelta( + result, isError, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"code_execution_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionResultStep.java b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionResultStep.java new file mode 100644 index 00000000000..529a3e4f2cc --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CodeExecutionResultStep.java @@ -0,0 +1,315 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * CodeExecutionResultStep + * + *

Code execution result step. + */ +@SuppressWarnings("all") +public class CodeExecutionResultStep { + + @JsonProperty("type") + private String type; + + /** + * Required. The output of the code execution. + */ + @JsonProperty("result") + private String result; + + /** + * Whether the code execution resulted in an error. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("is_error") + private Optional isError; + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonProperty("call_id") + private String callId; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public CodeExecutionResultStep( + @JsonProperty("result") String result, + @JsonProperty("is_error") Optional isError, + @JsonProperty("call_id") String callId, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(isError, "isError"); + Utils.checkNotNull(callId, "callId"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.isError = isError; + this.callId = callId; + this.signature = signature; + } + + public CodeExecutionResultStep( + String result, + String callId) { + this(result, Optional.empty(), callId, + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. The output of the code execution. + */ + @JsonIgnore + public String result() { + return result; + } + + /** + * Whether the code execution resulted in an error. + */ + @JsonIgnore + public Optional isError() { + return isError; + } + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonIgnore + public String callId() { + return callId; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. The output of the code execution. + */ + public CodeExecutionResultStep withResult(String result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + /** + * Whether the code execution resulted in an error. + */ + public CodeExecutionResultStep withIsError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + + /** + * Whether the code execution resulted in an error. + */ + public CodeExecutionResultStep withIsError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + /** + * Required. ID to match the ID from the function call block. + */ + public CodeExecutionResultStep withCallId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + /** + * A signature hash for backend validation. + */ + public CodeExecutionResultStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public CodeExecutionResultStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CodeExecutionResultStep other = (CodeExecutionResultStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.isError, other.isError) && + Utils.enhancedDeepEquals(this.callId, other.callId) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, isError, + callId, signature); + } + + @Override + public String toString() { + return Utils.toString(CodeExecutionResultStep.class, + "type", type, + "result", result, + "isError", isError, + "callId", callId, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String result; + + private Optional isError = Optional.empty(); + + private String callId; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. The output of the code execution. + */ + public Builder result(String result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + /** + * Whether the code execution resulted in an error. + */ + public Builder isError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + /** + * Whether the code execution resulted in an error. + */ + public Builder isError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public Builder callId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public CodeExecutionResultStep build() { + + return new CodeExecutionResultStep( + result, isError, callId, + signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"code_execution_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ComputerUse.java b/src/main/java/com/google/genai/gaos/models/interactions/ComputerUse.java new file mode 100644 index 00000000000..cca75489c51 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ComputerUse.java @@ -0,0 +1,364 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * ComputerUse + * + *

A tool that can be used by the model to interact with the computer. + */ +@SuppressWarnings("all") +public class ComputerUse { + + @JsonProperty("type") + private String type; + + /** + * The environment being operated. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("environment") + private Optional environment; + + /** + * The list of predefined functions that are excluded from the model call. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("excluded_predefined_functions") + private Optional> excludedPredefinedFunctions; + + /** + * Whether enable the prompt injection detection check on computer-use + * request. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("enable_prompt_injection_detection") + private Optional enablePromptInjectionDetection; + + /** + * Optional. Disabled safety policies for computer use. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("disabled_safety_policies") + private Optional> disabledSafetyPolicies; + + @JsonCreator + public ComputerUse( + @JsonProperty("environment") Optional environment, + @JsonProperty("excluded_predefined_functions") Optional> excludedPredefinedFunctions, + @JsonProperty("enable_prompt_injection_detection") Optional enablePromptInjectionDetection, + @JsonProperty("disabled_safety_policies") Optional> disabledSafetyPolicies) { + Utils.checkNotNull(environment, "environment"); + Utils.checkNotNull(excludedPredefinedFunctions, "excludedPredefinedFunctions"); + Utils.checkNotNull(enablePromptInjectionDetection, "enablePromptInjectionDetection"); + Utils.checkNotNull(disabledSafetyPolicies, "disabledSafetyPolicies"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.environment = environment; + this.excludedPredefinedFunctions = excludedPredefinedFunctions; + this.enablePromptInjectionDetection = enablePromptInjectionDetection; + this.disabledSafetyPolicies = disabledSafetyPolicies; + } + + public ComputerUse() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The environment being operated. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional environment() { + return (Optional) environment; + } + + /** + * The list of predefined functions that are excluded from the model call. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> excludedPredefinedFunctions() { + return (Optional>) excludedPredefinedFunctions; + } + + /** + * Whether enable the prompt injection detection check on computer-use + * request. + */ + @JsonIgnore + public Optional enablePromptInjectionDetection() { + return enablePromptInjectionDetection; + } + + /** + * Optional. Disabled safety policies for computer use. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> disabledSafetyPolicies() { + return (Optional>) disabledSafetyPolicies; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The environment being operated. + */ + public ComputerUse withEnvironment(EnvironmentEnum environment) { + Utils.checkNotNull(environment, "environment"); + this.environment = Optional.ofNullable(environment); + return this; + } + + + /** + * The environment being operated. + */ + public ComputerUse withEnvironment(Optional environment) { + Utils.checkNotNull(environment, "environment"); + this.environment = environment; + return this; + } + + /** + * The list of predefined functions that are excluded from the model call. + */ + public ComputerUse withExcludedPredefinedFunctions(List excludedPredefinedFunctions) { + Utils.checkNotNull(excludedPredefinedFunctions, "excludedPredefinedFunctions"); + this.excludedPredefinedFunctions = Optional.ofNullable(excludedPredefinedFunctions); + return this; + } + + + /** + * The list of predefined functions that are excluded from the model call. + */ + public ComputerUse withExcludedPredefinedFunctions(Optional> excludedPredefinedFunctions) { + Utils.checkNotNull(excludedPredefinedFunctions, "excludedPredefinedFunctions"); + this.excludedPredefinedFunctions = excludedPredefinedFunctions; + return this; + } + + /** + * Whether enable the prompt injection detection check on computer-use + * request. + */ + public ComputerUse withEnablePromptInjectionDetection(boolean enablePromptInjectionDetection) { + Utils.checkNotNull(enablePromptInjectionDetection, "enablePromptInjectionDetection"); + this.enablePromptInjectionDetection = Optional.ofNullable(enablePromptInjectionDetection); + return this; + } + + + /** + * Whether enable the prompt injection detection check on computer-use + * request. + */ + public ComputerUse withEnablePromptInjectionDetection(Optional enablePromptInjectionDetection) { + Utils.checkNotNull(enablePromptInjectionDetection, "enablePromptInjectionDetection"); + this.enablePromptInjectionDetection = enablePromptInjectionDetection; + return this; + } + + /** + * Optional. Disabled safety policies for computer use. + */ + public ComputerUse withDisabledSafetyPolicies(List disabledSafetyPolicies) { + Utils.checkNotNull(disabledSafetyPolicies, "disabledSafetyPolicies"); + this.disabledSafetyPolicies = Optional.ofNullable(disabledSafetyPolicies); + return this; + } + + + /** + * Optional. Disabled safety policies for computer use. + */ + public ComputerUse withDisabledSafetyPolicies(Optional> disabledSafetyPolicies) { + Utils.checkNotNull(disabledSafetyPolicies, "disabledSafetyPolicies"); + this.disabledSafetyPolicies = disabledSafetyPolicies; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ComputerUse other = (ComputerUse) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.environment, other.environment) && + Utils.enhancedDeepEquals(this.excludedPredefinedFunctions, other.excludedPredefinedFunctions) && + Utils.enhancedDeepEquals(this.enablePromptInjectionDetection, other.enablePromptInjectionDetection) && + Utils.enhancedDeepEquals(this.disabledSafetyPolicies, other.disabledSafetyPolicies); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, environment, excludedPredefinedFunctions, + enablePromptInjectionDetection, disabledSafetyPolicies); + } + + @Override + public String toString() { + return Utils.toString(ComputerUse.class, + "type", type, + "environment", environment, + "excludedPredefinedFunctions", excludedPredefinedFunctions, + "enablePromptInjectionDetection", enablePromptInjectionDetection, + "disabledSafetyPolicies", disabledSafetyPolicies); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional environment = Optional.empty(); + + private Optional> excludedPredefinedFunctions = Optional.empty(); + + private Optional enablePromptInjectionDetection = Optional.empty(); + + private Optional> disabledSafetyPolicies = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The environment being operated. + */ + public Builder environment(EnvironmentEnum environment) { + Utils.checkNotNull(environment, "environment"); + this.environment = Optional.ofNullable(environment); + return this; + } + + /** + * The environment being operated. + */ + public Builder environment(Optional environment) { + Utils.checkNotNull(environment, "environment"); + this.environment = environment; + return this; + } + + + /** + * The list of predefined functions that are excluded from the model call. + */ + public Builder excludedPredefinedFunctions(List excludedPredefinedFunctions) { + Utils.checkNotNull(excludedPredefinedFunctions, "excludedPredefinedFunctions"); + this.excludedPredefinedFunctions = Optional.ofNullable(excludedPredefinedFunctions); + return this; + } + + /** + * The list of predefined functions that are excluded from the model call. + */ + public Builder excludedPredefinedFunctions(Optional> excludedPredefinedFunctions) { + Utils.checkNotNull(excludedPredefinedFunctions, "excludedPredefinedFunctions"); + this.excludedPredefinedFunctions = excludedPredefinedFunctions; + return this; + } + + + /** + * Whether enable the prompt injection detection check on computer-use + * request. + */ + public Builder enablePromptInjectionDetection(boolean enablePromptInjectionDetection) { + Utils.checkNotNull(enablePromptInjectionDetection, "enablePromptInjectionDetection"); + this.enablePromptInjectionDetection = Optional.ofNullable(enablePromptInjectionDetection); + return this; + } + + /** + * Whether enable the prompt injection detection check on computer-use + * request. + */ + public Builder enablePromptInjectionDetection(Optional enablePromptInjectionDetection) { + Utils.checkNotNull(enablePromptInjectionDetection, "enablePromptInjectionDetection"); + this.enablePromptInjectionDetection = enablePromptInjectionDetection; + return this; + } + + + /** + * Optional. Disabled safety policies for computer use. + */ + public Builder disabledSafetyPolicies(List disabledSafetyPolicies) { + Utils.checkNotNull(disabledSafetyPolicies, "disabledSafetyPolicies"); + this.disabledSafetyPolicies = Optional.ofNullable(disabledSafetyPolicies); + return this; + } + + /** + * Optional. Disabled safety policies for computer use. + */ + public Builder disabledSafetyPolicies(Optional> disabledSafetyPolicies) { + Utils.checkNotNull(disabledSafetyPolicies, "disabledSafetyPolicies"); + this.disabledSafetyPolicies = disabledSafetyPolicies; + return this; + } + + public ComputerUse build() { + + return new ComputerUse( + environment, excludedPredefinedFunctions, enablePromptInjectionDetection, + disabledSafetyPolicies); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"computer_use\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Content.java b/src/main/java/com/google/genai/gaos/models/interactions/Content.java new file mode 100644 index 00000000000..381410b8fd1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Content.java @@ -0,0 +1,137 @@ +/* +* 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.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; + +/** + * Content + * + *

The content of the response. + */ +@JsonDeserialize(using = Content._Deserializer.class) +@SuppressWarnings("all") +public class Content { + + @JsonValue + private final TypedObject value; + + private Content(TypedObject value) { + this.value = value; + } + + public static Content of(TextContent value) { + Utils.checkNotNull(value, "value"); + return new Content(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Content of(ImageContent value) { + Utils.checkNotNull(value, "value"); + return new Content(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Content of(AudioContent value) { + Utils.checkNotNull(value, "value"); + return new Content(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Content of(DocumentContent value) { + Utils.checkNotNull(value, "value"); + return new Content(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Content of(VideoContent value) { + Utils.checkNotNull(value, "value"); + return new Content(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.TextContent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ImageContent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.AudioContent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.DocumentContent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.VideoContent}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Content other = (Content) 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(Content.class, false, + 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)); + } + } + + @Override + public String toString() { + return Utils.toString(Content.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteraction.java b/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteraction.java new file mode 100644 index 00000000000..795d65f576e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteraction.java @@ -0,0 +1,735 @@ +/* +* 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. +*/ + +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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.Nonnull; +import jakarta.annotation.Nullable; +import java.lang.Boolean; +import java.lang.Deprecated; +import java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + +/** + * CreateAgentInteraction + * + *

Parameters for creating agent interactions + */ +@SuppressWarnings("all") +public class CreateAgentInteraction { + /** + * The agent to interact with. + */ + @JsonProperty("agent") + private AgentOption agent; + + /** + * Input only. Whether to run the model interaction in the background. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("background") + private Boolean background; + + /** + * Input only. Whether to store the response and request for later retrieval. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("store") + private Boolean store; + + /** + * Input only. Whether the interaction will be streamed. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("stream") + private Boolean stream; + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("environment") + private CreateAgentInteractionEnvironment environment; + + /** + * The ID of the previous interaction, if any. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("previous_interaction_id") + private String previousInteractionId; + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_mime_type") + @Deprecated + private String responseMimeType; + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_modalities") + private List responseModalities; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("service_tier") + private ServiceTier serviceTier; + + /** + * System instruction for the interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("system_instruction") + private String systemInstruction; + + /** + * A list of tool declarations the model may call during interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("tools") + private List tools; + + /** + * Statistics on the interaction request's token usage. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("usage") + private Usage usage; + + /** + * Message for configuring webhook events for a request. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("webhook_config") + private WebhookConfig webhookConfig; + + /** + * Configuration parameters for the agent interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("agent_config") + private CreateAgentInteractionAgentConfig agentConfig; + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_format") + private CreateAgentInteractionResponseFormat responseFormat; + + /** + * The input for the interaction. + */ + @JsonProperty("input") + private InteractionsInput input; + + @JsonCreator + public CreateAgentInteraction( + @JsonProperty("agent") @Nonnull AgentOption agent, + @JsonProperty("background") @Nullable Boolean background, + @JsonProperty("store") @Nullable Boolean store, + @JsonProperty("stream") @Nullable Boolean stream, + @JsonProperty("environment") @Nullable CreateAgentInteractionEnvironment environment, + @JsonProperty("previous_interaction_id") @Nullable String previousInteractionId, + @JsonProperty("response_mime_type") @Nullable String responseMimeType, + @JsonProperty("response_modalities") @Nullable List responseModalities, + @JsonProperty("service_tier") @Nullable ServiceTier serviceTier, + @JsonProperty("system_instruction") @Nullable String systemInstruction, + @JsonProperty("tools") @Nullable List tools, + @JsonProperty("usage") @Nullable Usage usage, + @JsonProperty("webhook_config") @Nullable WebhookConfig webhookConfig, + @JsonProperty("agent_config") @Nullable CreateAgentInteractionAgentConfig agentConfig, + @JsonProperty("response_format") @Nullable CreateAgentInteractionResponseFormat responseFormat, + @JsonProperty("input") @Nonnull InteractionsInput input) { + this.agent = Optional.ofNullable(agent) + .orElseThrow(() -> new IllegalArgumentException("agent cannot be null")); + this.background = background; + this.store = store; + this.stream = stream; + this.environment = environment; + this.previousInteractionId = previousInteractionId; + this.responseMimeType = responseMimeType; + this.responseModalities = responseModalities; + this.serviceTier = serviceTier; + this.systemInstruction = systemInstruction; + this.tools = tools; + this.usage = usage; + this.webhookConfig = webhookConfig; + this.agentConfig = agentConfig; + this.responseFormat = responseFormat; + this.input = Optional.ofNullable(input) + .orElseThrow(() -> new IllegalArgumentException("input cannot be null")); + } + + public CreateAgentInteraction( + @Nonnull AgentOption agent, + @Nonnull InteractionsInput input) { + this(agent, null, null, + null, null, null, + null, null, null, + null, null, null, + null, null, null, + input); + } + + /** + * The agent to interact with. + */ + public AgentOption agent() { + return this.agent; + } + + /** + * Input only. Whether to run the model interaction in the background. + */ + public Optional background() { + return Optional.ofNullable(this.background); + } + + /** + * Input only. Whether to store the response and request for later retrieval. + */ + public Optional store() { + return Optional.ofNullable(this.store); + } + + /** + * Input only. Whether the interaction will be streamed. + */ + public Optional stream() { + return Optional.ofNullable(this.stream); + } + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public Optional environment() { + return Optional.ofNullable(this.environment); + } + + /** + * The ID of the previous interaction, if any. + */ + public Optional previousInteractionId() { + return Optional.ofNullable(this.previousInteractionId); + } + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Optional responseMimeType() { + return Optional.ofNullable(this.responseMimeType); + } + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public Optional> responseModalities() { + return Optional.ofNullable(this.responseModalities); + } + + public Optional serviceTier() { + return Optional.ofNullable(this.serviceTier); + } + + /** + * System instruction for the interaction. + */ + public Optional systemInstruction() { + return Optional.ofNullable(this.systemInstruction); + } + + /** + * A list of tool declarations the model may call during interaction. + */ + public Optional> tools() { + return Optional.ofNullable(this.tools); + } + + /** + * Statistics on the interaction request's token usage. + */ + public Optional usage() { + return Optional.ofNullable(this.usage); + } + + /** + * Message for configuring webhook events for a request. + */ + public Optional webhookConfig() { + return Optional.ofNullable(this.webhookConfig); + } + + /** + * Configuration parameters for the agent interaction. + */ + public Optional agentConfig() { + return Optional.ofNullable(this.agentConfig); + } + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public Optional responseFormat() { + return Optional.ofNullable(this.responseFormat); + } + + /** + * The input for the interaction. + */ + public InteractionsInput input() { + return this.input; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The agent to interact with. + */ + public CreateAgentInteraction withAgent(@Nonnull AgentOption agent) { + this.agent = Utils.checkNotNull(agent, "agent"); + return this; + } + + + /** + * Input only. Whether to run the model interaction in the background. + */ + public CreateAgentInteraction withBackground(@Nullable Boolean background) { + this.background = background; + return this; + } + + + /** + * Input only. Whether to store the response and request for later retrieval. + */ + public CreateAgentInteraction withStore(@Nullable Boolean store) { + this.store = store; + return this; + } + + + /** + * Input only. Whether the interaction will be streamed. + */ + public CreateAgentInteraction withStream(@Nullable Boolean stream) { + this.stream = stream; + return this; + } + + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public CreateAgentInteraction withEnvironment(@Nullable CreateAgentInteractionEnvironment environment) { + this.environment = environment; + return this; + } + + + /** + * The ID of the previous interaction, if any. + */ + public CreateAgentInteraction withPreviousInteractionId(@Nullable String previousInteractionId) { + this.previousInteractionId = previousInteractionId; + return this; + } + + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public CreateAgentInteraction withResponseMimeType(@Nullable String responseMimeType) { + this.responseMimeType = responseMimeType; + return this; + } + + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public CreateAgentInteraction withResponseModalities(@Nullable List responseModalities) { + this.responseModalities = responseModalities; + return this; + } + + + public CreateAgentInteraction withServiceTier(@Nullable ServiceTier serviceTier) { + this.serviceTier = serviceTier; + return this; + } + + + /** + * System instruction for the interaction. + */ + public CreateAgentInteraction withSystemInstruction(@Nullable String systemInstruction) { + this.systemInstruction = systemInstruction; + return this; + } + + + /** + * A list of tool declarations the model may call during interaction. + */ + public CreateAgentInteraction withTools(@Nullable List tools) { + this.tools = tools; + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public CreateAgentInteraction withUsage(@Nullable Usage usage) { + this.usage = usage; + return this; + } + + + /** + * Message for configuring webhook events for a request. + */ + public CreateAgentInteraction withWebhookConfig(@Nullable WebhookConfig webhookConfig) { + this.webhookConfig = webhookConfig; + return this; + } + + + /** + * Configuration parameters for the agent interaction. + */ + public CreateAgentInteraction withAgentConfig(@Nullable CreateAgentInteractionAgentConfig agentConfig) { + this.agentConfig = agentConfig; + return this; + } + + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public CreateAgentInteraction withResponseFormat(@Nullable CreateAgentInteractionResponseFormat responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + + /** + * The input for the interaction. + */ + public CreateAgentInteraction withInput(@Nonnull InteractionsInput input) { + this.input = Utils.checkNotNull(input, "input"); + return this; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateAgentInteraction other = (CreateAgentInteraction) o; + return + Utils.enhancedDeepEquals(this.agent, other.agent) && + Utils.enhancedDeepEquals(this.background, other.background) && + Utils.enhancedDeepEquals(this.store, other.store) && + Utils.enhancedDeepEquals(this.stream, other.stream) && + Utils.enhancedDeepEquals(this.environment, other.environment) && + Utils.enhancedDeepEquals(this.previousInteractionId, other.previousInteractionId) && + Utils.enhancedDeepEquals(this.responseMimeType, other.responseMimeType) && + Utils.enhancedDeepEquals(this.responseModalities, other.responseModalities) && + Utils.enhancedDeepEquals(this.serviceTier, other.serviceTier) && + Utils.enhancedDeepEquals(this.systemInstruction, other.systemInstruction) && + Utils.enhancedDeepEquals(this.tools, other.tools) && + Utils.enhancedDeepEquals(this.usage, other.usage) && + Utils.enhancedDeepEquals(this.webhookConfig, other.webhookConfig) && + Utils.enhancedDeepEquals(this.agentConfig, other.agentConfig) && + Utils.enhancedDeepEquals(this.responseFormat, other.responseFormat) && + Utils.enhancedDeepEquals(this.input, other.input); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + agent, background, store, + stream, environment, previousInteractionId, + responseMimeType, responseModalities, serviceTier, + systemInstruction, tools, usage, + webhookConfig, agentConfig, responseFormat, + input); + } + + @Override + public String toString() { + return Utils.toString(CreateAgentInteraction.class, + "agent", agent, + "background", background, + "store", store, + "stream", stream, + "environment", environment, + "previousInteractionId", previousInteractionId, + "responseMimeType", responseMimeType, + "responseModalities", responseModalities, + "serviceTier", serviceTier, + "systemInstruction", systemInstruction, + "tools", tools, + "usage", usage, + "webhookConfig", webhookConfig, + "agentConfig", agentConfig, + "responseFormat", responseFormat, + "input", input); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private AgentOption agent; + + private Boolean background; + + private Boolean store; + + private Boolean stream; + + private CreateAgentInteractionEnvironment environment; + + private String previousInteractionId; + + @Deprecated + private String responseMimeType; + + private List responseModalities; + + private ServiceTier serviceTier; + + private String systemInstruction; + + private List tools; + + private Usage usage; + + private WebhookConfig webhookConfig; + + private CreateAgentInteractionAgentConfig agentConfig; + + private CreateAgentInteractionResponseFormat responseFormat; + + private InteractionsInput input; + + private Builder() { + // force use of static builder() method + } + + /** + * The agent to interact with. + */ + public Builder agent(@Nonnull AgentOption agent) { + this.agent = Utils.checkNotNull(agent, "agent"); + return this; + } + + /** + * The agent to interact with. + */ + public Builder agent(@Nonnull String agent) { + this.agent = AgentOption.of(Utils.checkNotNull(agent, "agent")); + return this; + } + + /** + * Input only. Whether to run the model interaction in the background. + */ + public Builder background(@Nullable Boolean background) { + this.background = background; + return this; + } + + /** + * Input only. Whether to store the response and request for later retrieval. + */ + public Builder store(@Nullable Boolean store) { + this.store = store; + return this; + } + + /** + * Input only. Whether the interaction will be streamed. + */ + public Builder stream(@Nullable Boolean stream) { + this.stream = stream; + return this; + } + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public Builder environment(@Nullable CreateAgentInteractionEnvironment environment) { + this.environment = environment; + return this; + } + + /** + * The ID of the previous interaction, if any. + */ + public Builder previousInteractionId(@Nullable String previousInteractionId) { + this.previousInteractionId = previousInteractionId; + return this; + } + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder responseMimeType(@Nullable String responseMimeType) { + this.responseMimeType = responseMimeType; + return this; + } + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public Builder responseModalities(@Nullable List responseModalities) { + this.responseModalities = responseModalities; + return this; + } + + public Builder serviceTier(@Nullable ServiceTier serviceTier) { + this.serviceTier = serviceTier; + return this; + } + + /** + * System instruction for the interaction. + */ + public Builder systemInstruction(@Nullable String systemInstruction) { + this.systemInstruction = systemInstruction; + return this; + } + + /** + * A list of tool declarations the model may call during interaction. + */ + public Builder tools(@Nullable List tools) { + this.tools = tools; + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Builder usage(@Nullable Usage usage) { + this.usage = usage; + return this; + } + + /** + * Message for configuring webhook events for a request. + */ + public Builder webhookConfig(@Nullable WebhookConfig webhookConfig) { + this.webhookConfig = webhookConfig; + return this; + } + + /** + * Configuration parameters for the agent interaction. + */ + public Builder agentConfig(@Nullable CreateAgentInteractionAgentConfig agentConfig) { + this.agentConfig = agentConfig; + return this; + } + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public Builder responseFormat(@Nullable CreateAgentInteractionResponseFormat responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * The input for the interaction. + */ + public Builder input(@Nonnull InteractionsInput input) { + this.input = Utils.checkNotNull(input, "input"); + return this; + } + + public CreateAgentInteraction build() { + return new CreateAgentInteraction( + agent, background, store, + stream, environment, previousInteractionId, + responseMimeType, responseModalities, serviceTier, + systemInstruction, tools, usage, + webhookConfig, agentConfig, responseFormat, + input); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionAgentConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionAgentConfig.java new file mode 100644 index 00000000000..6f57f490da1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionAgentConfig.java @@ -0,0 +1,116 @@ +/* +* 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.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; + +/** + * CreateAgentInteractionAgentConfig + * + *

Configuration parameters for the agent interaction. + */ +@JsonDeserialize(using = CreateAgentInteractionAgentConfig._Deserializer.class) +@SuppressWarnings("all") +public class CreateAgentInteractionAgentConfig { + + @JsonValue + private final TypedObject value; + + private CreateAgentInteractionAgentConfig(TypedObject value) { + this.value = value; + } + + public static CreateAgentInteractionAgentConfig of(DynamicAgentConfig value) { + Utils.checkNotNull(value, "value"); + return new CreateAgentInteractionAgentConfig(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static CreateAgentInteractionAgentConfig of(DeepResearchAgentConfig value) { + Utils.checkNotNull(value, "value"); + return new CreateAgentInteractionAgentConfig(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.DynamicAgentConfig}
  • + *
  • {@code com.google.genai.gaos.models.interactions.DeepResearchAgentConfig}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateAgentInteractionAgentConfig other = (CreateAgentInteractionAgentConfig) 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(CreateAgentInteractionAgentConfig.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(CreateAgentInteractionAgentConfig.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionEnvironment.java b/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionEnvironment.java new file mode 100644 index 00000000000..b4a58d4d22f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionEnvironment.java @@ -0,0 +1,117 @@ +/* +* 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.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; + +/** + * CreateAgentInteractionEnvironment + * + *

The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ +@JsonDeserialize(using = CreateAgentInteractionEnvironment._Deserializer.class) +@SuppressWarnings("all") +public class CreateAgentInteractionEnvironment { + + @JsonValue + private final TypedObject value; + + private CreateAgentInteractionEnvironment(TypedObject value) { + this.value = value; + } + + public static CreateAgentInteractionEnvironment of(String value) { + Utils.checkNotNull(value, "value"); + return new CreateAgentInteractionEnvironment(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static CreateAgentInteractionEnvironment of(Environment value) { + Utils.checkNotNull(value, "value"); + return new CreateAgentInteractionEnvironment(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code java.lang.String}
  • + *
  • {@code com.google.genai.gaos.models.interactions.Environment}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateAgentInteractionEnvironment other = (CreateAgentInteractionEnvironment) 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(CreateAgentInteractionEnvironment.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(CreateAgentInteractionEnvironment.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionResponseFormat.java b/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionResponseFormat.java new file mode 100644 index 00000000000..77e1e41940d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CreateAgentInteractionResponseFormat.java @@ -0,0 +1,118 @@ +/* +* 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.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.List; + +/** + * CreateAgentInteractionResponseFormat + * + *

Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ +@JsonDeserialize(using = CreateAgentInteractionResponseFormat._Deserializer.class) +@SuppressWarnings("all") +public class CreateAgentInteractionResponseFormat { + + @JsonValue + private final TypedObject value; + + private CreateAgentInteractionResponseFormat(TypedObject value) { + this.value = value; + } + + public static CreateAgentInteractionResponseFormat of(List value) { + Utils.checkNotNull(value, "value"); + return new CreateAgentInteractionResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static CreateAgentInteractionResponseFormat of(ResponseFormat value) { + Utils.checkNotNull(value, "value"); + return new CreateAgentInteractionResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code java.util.List}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ResponseFormat}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateAgentInteractionResponseFormat other = (CreateAgentInteractionResponseFormat) 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(CreateAgentInteractionResponseFormat.class, false, + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(CreateAgentInteractionResponseFormat.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteraction.java b/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteraction.java new file mode 100644 index 00000000000..63fdfd24ee8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteraction.java @@ -0,0 +1,740 @@ +/* +* 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. +*/ + +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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.Nonnull; +import jakarta.annotation.Nullable; +import java.lang.Boolean; +import java.lang.Deprecated; +import java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + +/** + * CreateModelInteraction + * + *

Parameters for creating model interactions + */ +@SuppressWarnings("all") +public class CreateModelInteraction { + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + @JsonProperty("model") + private Model model; + + /** + * Input only. Whether to run the model interaction in the background. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("background") + private Boolean background; + + /** + * Input only. Whether to store the response and request for later retrieval. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("store") + private Boolean store; + + /** + * Input only. Whether the interaction will be streamed. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("stream") + private Boolean stream; + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("environment") + private CreateModelInteractionEnvironment environment; + + /** + * The ID of the previous interaction, if any. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("previous_interaction_id") + private String previousInteractionId; + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_mime_type") + @Deprecated + private String responseMimeType; + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_modalities") + private List responseModalities; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("service_tier") + private ServiceTier serviceTier; + + /** + * System instruction for the interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("system_instruction") + private String systemInstruction; + + /** + * A list of tool declarations the model may call during interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("tools") + private List tools; + + /** + * Statistics on the interaction request's token usage. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("usage") + private Usage usage; + + /** + * Message for configuring webhook events for a request. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("webhook_config") + private WebhookConfig webhookConfig; + + /** + * Configuration parameters for model interactions. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("generation_config") + private GenerationConfig generationConfig; + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_format") + private CreateModelInteractionResponseFormat responseFormat; + + /** + * The input for the interaction. + */ + @JsonProperty("input") + private InteractionsInput input; + + @JsonCreator + public CreateModelInteraction( + @JsonProperty("model") @Nonnull Model model, + @JsonProperty("background") @Nullable Boolean background, + @JsonProperty("store") @Nullable Boolean store, + @JsonProperty("stream") @Nullable Boolean stream, + @JsonProperty("environment") @Nullable CreateModelInteractionEnvironment environment, + @JsonProperty("previous_interaction_id") @Nullable String previousInteractionId, + @JsonProperty("response_mime_type") @Nullable String responseMimeType, + @JsonProperty("response_modalities") @Nullable List responseModalities, + @JsonProperty("service_tier") @Nullable ServiceTier serviceTier, + @JsonProperty("system_instruction") @Nullable String systemInstruction, + @JsonProperty("tools") @Nullable List tools, + @JsonProperty("usage") @Nullable Usage usage, + @JsonProperty("webhook_config") @Nullable WebhookConfig webhookConfig, + @JsonProperty("generation_config") @Nullable GenerationConfig generationConfig, + @JsonProperty("response_format") @Nullable CreateModelInteractionResponseFormat responseFormat, + @JsonProperty("input") @Nonnull InteractionsInput input) { + this.model = Optional.ofNullable(model) + .orElseThrow(() -> new IllegalArgumentException("model cannot be null")); + this.background = background; + this.store = store; + this.stream = stream; + this.environment = environment; + this.previousInteractionId = previousInteractionId; + this.responseMimeType = responseMimeType; + this.responseModalities = responseModalities; + this.serviceTier = serviceTier; + this.systemInstruction = systemInstruction; + this.tools = tools; + this.usage = usage; + this.webhookConfig = webhookConfig; + this.generationConfig = generationConfig; + this.responseFormat = responseFormat; + this.input = Optional.ofNullable(input) + .orElseThrow(() -> new IllegalArgumentException("input cannot be null")); + } + + public CreateModelInteraction( + @Nonnull Model model, + @Nonnull InteractionsInput input) { + this(model, null, null, + null, null, null, + null, null, null, + null, null, null, + null, null, null, + input); + } + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + public Model model() { + return this.model; + } + + /** + * Input only. Whether to run the model interaction in the background. + */ + public Optional background() { + return Optional.ofNullable(this.background); + } + + /** + * Input only. Whether to store the response and request for later retrieval. + */ + public Optional store() { + return Optional.ofNullable(this.store); + } + + /** + * Input only. Whether the interaction will be streamed. + */ + public Optional stream() { + return Optional.ofNullable(this.stream); + } + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public Optional environment() { + return Optional.ofNullable(this.environment); + } + + /** + * The ID of the previous interaction, if any. + */ + public Optional previousInteractionId() { + return Optional.ofNullable(this.previousInteractionId); + } + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Optional responseMimeType() { + return Optional.ofNullable(this.responseMimeType); + } + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public Optional> responseModalities() { + return Optional.ofNullable(this.responseModalities); + } + + public Optional serviceTier() { + return Optional.ofNullable(this.serviceTier); + } + + /** + * System instruction for the interaction. + */ + public Optional systemInstruction() { + return Optional.ofNullable(this.systemInstruction); + } + + /** + * A list of tool declarations the model may call during interaction. + */ + public Optional> tools() { + return Optional.ofNullable(this.tools); + } + + /** + * Statistics on the interaction request's token usage. + */ + public Optional usage() { + return Optional.ofNullable(this.usage); + } + + /** + * Message for configuring webhook events for a request. + */ + public Optional webhookConfig() { + return Optional.ofNullable(this.webhookConfig); + } + + /** + * Configuration parameters for model interactions. + */ + public Optional generationConfig() { + return Optional.ofNullable(this.generationConfig); + } + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public Optional responseFormat() { + return Optional.ofNullable(this.responseFormat); + } + + /** + * The input for the interaction. + */ + public InteractionsInput input() { + return this.input; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + public CreateModelInteraction withModel(@Nonnull Model model) { + this.model = Utils.checkNotNull(model, "model"); + return this; + } + + + /** + * Input only. Whether to run the model interaction in the background. + */ + public CreateModelInteraction withBackground(@Nullable Boolean background) { + this.background = background; + return this; + } + + + /** + * Input only. Whether to store the response and request for later retrieval. + */ + public CreateModelInteraction withStore(@Nullable Boolean store) { + this.store = store; + return this; + } + + + /** + * Input only. Whether the interaction will be streamed. + */ + public CreateModelInteraction withStream(@Nullable Boolean stream) { + this.stream = stream; + return this; + } + + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public CreateModelInteraction withEnvironment(@Nullable CreateModelInteractionEnvironment environment) { + this.environment = environment; + return this; + } + + + /** + * The ID of the previous interaction, if any. + */ + public CreateModelInteraction withPreviousInteractionId(@Nullable String previousInteractionId) { + this.previousInteractionId = previousInteractionId; + return this; + } + + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public CreateModelInteraction withResponseMimeType(@Nullable String responseMimeType) { + this.responseMimeType = responseMimeType; + return this; + } + + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public CreateModelInteraction withResponseModalities(@Nullable List responseModalities) { + this.responseModalities = responseModalities; + return this; + } + + + public CreateModelInteraction withServiceTier(@Nullable ServiceTier serviceTier) { + this.serviceTier = serviceTier; + return this; + } + + + /** + * System instruction for the interaction. + */ + public CreateModelInteraction withSystemInstruction(@Nullable String systemInstruction) { + this.systemInstruction = systemInstruction; + return this; + } + + + /** + * A list of tool declarations the model may call during interaction. + */ + public CreateModelInteraction withTools(@Nullable List tools) { + this.tools = tools; + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public CreateModelInteraction withUsage(@Nullable Usage usage) { + this.usage = usage; + return this; + } + + + /** + * Message for configuring webhook events for a request. + */ + public CreateModelInteraction withWebhookConfig(@Nullable WebhookConfig webhookConfig) { + this.webhookConfig = webhookConfig; + return this; + } + + + /** + * Configuration parameters for model interactions. + */ + public CreateModelInteraction withGenerationConfig(@Nullable GenerationConfig generationConfig) { + this.generationConfig = generationConfig; + return this; + } + + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public CreateModelInteraction withResponseFormat(@Nullable CreateModelInteractionResponseFormat responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + + /** + * The input for the interaction. + */ + public CreateModelInteraction withInput(@Nonnull InteractionsInput input) { + this.input = Utils.checkNotNull(input, "input"); + return this; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateModelInteraction other = (CreateModelInteraction) o; + return + Utils.enhancedDeepEquals(this.model, other.model) && + Utils.enhancedDeepEquals(this.background, other.background) && + Utils.enhancedDeepEquals(this.store, other.store) && + Utils.enhancedDeepEquals(this.stream, other.stream) && + Utils.enhancedDeepEquals(this.environment, other.environment) && + Utils.enhancedDeepEquals(this.previousInteractionId, other.previousInteractionId) && + Utils.enhancedDeepEquals(this.responseMimeType, other.responseMimeType) && + Utils.enhancedDeepEquals(this.responseModalities, other.responseModalities) && + Utils.enhancedDeepEquals(this.serviceTier, other.serviceTier) && + Utils.enhancedDeepEquals(this.systemInstruction, other.systemInstruction) && + Utils.enhancedDeepEquals(this.tools, other.tools) && + Utils.enhancedDeepEquals(this.usage, other.usage) && + Utils.enhancedDeepEquals(this.webhookConfig, other.webhookConfig) && + Utils.enhancedDeepEquals(this.generationConfig, other.generationConfig) && + Utils.enhancedDeepEquals(this.responseFormat, other.responseFormat) && + Utils.enhancedDeepEquals(this.input, other.input); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + model, background, store, + stream, environment, previousInteractionId, + responseMimeType, responseModalities, serviceTier, + systemInstruction, tools, usage, + webhookConfig, generationConfig, responseFormat, + input); + } + + @Override + public String toString() { + return Utils.toString(CreateModelInteraction.class, + "model", model, + "background", background, + "store", store, + "stream", stream, + "environment", environment, + "previousInteractionId", previousInteractionId, + "responseMimeType", responseMimeType, + "responseModalities", responseModalities, + "serviceTier", serviceTier, + "systemInstruction", systemInstruction, + "tools", tools, + "usage", usage, + "webhookConfig", webhookConfig, + "generationConfig", generationConfig, + "responseFormat", responseFormat, + "input", input); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Model model; + + private Boolean background; + + private Boolean store; + + private Boolean stream; + + private CreateModelInteractionEnvironment environment; + + private String previousInteractionId; + + @Deprecated + private String responseMimeType; + + private List responseModalities; + + private ServiceTier serviceTier; + + private String systemInstruction; + + private List tools; + + private Usage usage; + + private WebhookConfig webhookConfig; + + private GenerationConfig generationConfig; + + private CreateModelInteractionResponseFormat responseFormat; + + private InteractionsInput input; + + private Builder() { + // force use of static builder() method + } + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + public Builder model(@Nonnull Model model) { + this.model = Utils.checkNotNull(model, "model"); + return this; + } + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + public Builder model(@Nonnull String model) { + this.model = Model.of(Utils.checkNotNull(model, "model")); + return this; + } + + /** + * Input only. Whether to run the model interaction in the background. + */ + public Builder background(@Nullable Boolean background) { + this.background = background; + return this; + } + + /** + * Input only. Whether to store the response and request for later retrieval. + */ + public Builder store(@Nullable Boolean store) { + this.store = store; + return this; + } + + /** + * Input only. Whether the interaction will be streamed. + */ + public Builder stream(@Nullable Boolean stream) { + this.stream = stream; + return this; + } + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public Builder environment(@Nullable CreateModelInteractionEnvironment environment) { + this.environment = environment; + return this; + } + + /** + * The ID of the previous interaction, if any. + */ + public Builder previousInteractionId(@Nullable String previousInteractionId) { + this.previousInteractionId = previousInteractionId; + return this; + } + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder responseMimeType(@Nullable String responseMimeType) { + this.responseMimeType = responseMimeType; + return this; + } + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public Builder responseModalities(@Nullable List responseModalities) { + this.responseModalities = responseModalities; + return this; + } + + public Builder serviceTier(@Nullable ServiceTier serviceTier) { + this.serviceTier = serviceTier; + return this; + } + + /** + * System instruction for the interaction. + */ + public Builder systemInstruction(@Nullable String systemInstruction) { + this.systemInstruction = systemInstruction; + return this; + } + + /** + * A list of tool declarations the model may call during interaction. + */ + public Builder tools(@Nullable List tools) { + this.tools = tools; + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Builder usage(@Nullable Usage usage) { + this.usage = usage; + return this; + } + + /** + * Message for configuring webhook events for a request. + */ + public Builder webhookConfig(@Nullable WebhookConfig webhookConfig) { + this.webhookConfig = webhookConfig; + return this; + } + + /** + * Configuration parameters for model interactions. + */ + public Builder generationConfig(@Nullable GenerationConfig generationConfig) { + this.generationConfig = generationConfig; + return this; + } + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public Builder responseFormat(@Nullable CreateModelInteractionResponseFormat responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * The input for the interaction. + */ + public Builder input(@Nonnull InteractionsInput input) { + this.input = Utils.checkNotNull(input, "input"); + return this; + } + + public CreateModelInteraction build() { + return new CreateModelInteraction( + model, background, store, + stream, environment, previousInteractionId, + responseMimeType, responseModalities, serviceTier, + systemInstruction, tools, usage, + webhookConfig, generationConfig, responseFormat, + input); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteractionEnvironment.java b/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteractionEnvironment.java new file mode 100644 index 00000000000..0e103c88f2f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteractionEnvironment.java @@ -0,0 +1,117 @@ +/* +* 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.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; + +/** + * CreateModelInteractionEnvironment + * + *

The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ +@JsonDeserialize(using = CreateModelInteractionEnvironment._Deserializer.class) +@SuppressWarnings("all") +public class CreateModelInteractionEnvironment { + + @JsonValue + private final TypedObject value; + + private CreateModelInteractionEnvironment(TypedObject value) { + this.value = value; + } + + public static CreateModelInteractionEnvironment of(String value) { + Utils.checkNotNull(value, "value"); + return new CreateModelInteractionEnvironment(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static CreateModelInteractionEnvironment of(Environment value) { + Utils.checkNotNull(value, "value"); + return new CreateModelInteractionEnvironment(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code java.lang.String}
  • + *
  • {@code com.google.genai.gaos.models.interactions.Environment}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateModelInteractionEnvironment other = (CreateModelInteractionEnvironment) 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(CreateModelInteractionEnvironment.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(CreateModelInteractionEnvironment.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteractionResponseFormat.java b/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteractionResponseFormat.java new file mode 100644 index 00000000000..cf14e77740b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/CreateModelInteractionResponseFormat.java @@ -0,0 +1,118 @@ +/* +* 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.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.List; + +/** + * CreateModelInteractionResponseFormat + * + *

Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ +@JsonDeserialize(using = CreateModelInteractionResponseFormat._Deserializer.class) +@SuppressWarnings("all") +public class CreateModelInteractionResponseFormat { + + @JsonValue + private final TypedObject value; + + private CreateModelInteractionResponseFormat(TypedObject value) { + this.value = value; + } + + public static CreateModelInteractionResponseFormat of(List value) { + Utils.checkNotNull(value, "value"); + return new CreateModelInteractionResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static CreateModelInteractionResponseFormat of(ResponseFormat value) { + Utils.checkNotNull(value, "value"); + return new CreateModelInteractionResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code java.util.List}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ResponseFormat}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateModelInteractionResponseFormat other = (CreateModelInteractionResponseFormat) 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(CreateModelInteractionResponseFormat.class, false, + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(CreateModelInteractionResponseFormat.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/DeepResearchAgentConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/DeepResearchAgentConfig.java new file mode 100644 index 00000000000..f61734cb16e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/DeepResearchAgentConfig.java @@ -0,0 +1,357 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * DeepResearchAgentConfig + * + *

Configuration for the Deep Research agent. + */ +@SuppressWarnings("all") +public class DeepResearchAgentConfig { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("thinking_summaries") + private Optional thinkingSummaries; + + /** + * Whether to include visualizations in the response. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("visualization") + private Optional visualization; + + /** + * Enables human-in-the-loop planning for the Deep Research agent. If set to + * true, the Deep Research agent will provide a research plan in its response. + * The agent will then proceed only if the user confirms the plan in the next + * turn. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("collaborative_planning") + private Optional collaborativePlanning; + + /** + * Enables bigquery tool for the Deep Research agent. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("enable_bigquery_tool") + private Optional enableBigqueryTool; + + @JsonCreator + public DeepResearchAgentConfig( + @JsonProperty("thinking_summaries") Optional thinkingSummaries, + @JsonProperty("visualization") Optional visualization, + @JsonProperty("collaborative_planning") Optional collaborativePlanning, + @JsonProperty("enable_bigquery_tool") Optional enableBigqueryTool) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + Utils.checkNotNull(visualization, "visualization"); + Utils.checkNotNull(collaborativePlanning, "collaborativePlanning"); + Utils.checkNotNull(enableBigqueryTool, "enableBigqueryTool"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.thinkingSummaries = thinkingSummaries; + this.visualization = visualization; + this.collaborativePlanning = collaborativePlanning; + this.enableBigqueryTool = enableBigqueryTool; + } + + public DeepResearchAgentConfig() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional thinkingSummaries() { + return (Optional) thinkingSummaries; + } + + /** + * Whether to include visualizations in the response. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional visualization() { + return (Optional) visualization; + } + + /** + * Enables human-in-the-loop planning for the Deep Research agent. If set to + * true, the Deep Research agent will provide a research plan in its response. + * The agent will then proceed only if the user confirms the plan in the next + * turn. + */ + @JsonIgnore + public Optional collaborativePlanning() { + return collaborativePlanning; + } + + /** + * Enables bigquery tool for the Deep Research agent. + */ + @JsonIgnore + public Optional enableBigqueryTool() { + return enableBigqueryTool; + } + + public static Builder builder() { + return new Builder(); + } + + + public DeepResearchAgentConfig withThinkingSummaries(ThinkingSummaries thinkingSummaries) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + this.thinkingSummaries = Optional.ofNullable(thinkingSummaries); + return this; + } + + + public DeepResearchAgentConfig withThinkingSummaries(Optional thinkingSummaries) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + this.thinkingSummaries = thinkingSummaries; + return this; + } + + /** + * Whether to include visualizations in the response. + */ + public DeepResearchAgentConfig withVisualization(Visualization visualization) { + Utils.checkNotNull(visualization, "visualization"); + this.visualization = Optional.ofNullable(visualization); + return this; + } + + + /** + * Whether to include visualizations in the response. + */ + public DeepResearchAgentConfig withVisualization(Optional visualization) { + Utils.checkNotNull(visualization, "visualization"); + this.visualization = visualization; + return this; + } + + /** + * Enables human-in-the-loop planning for the Deep Research agent. If set to + * true, the Deep Research agent will provide a research plan in its response. + * The agent will then proceed only if the user confirms the plan in the next + * turn. + */ + public DeepResearchAgentConfig withCollaborativePlanning(boolean collaborativePlanning) { + Utils.checkNotNull(collaborativePlanning, "collaborativePlanning"); + this.collaborativePlanning = Optional.ofNullable(collaborativePlanning); + return this; + } + + + /** + * Enables human-in-the-loop planning for the Deep Research agent. If set to + * true, the Deep Research agent will provide a research plan in its response. + * The agent will then proceed only if the user confirms the plan in the next + * turn. + */ + public DeepResearchAgentConfig withCollaborativePlanning(Optional collaborativePlanning) { + Utils.checkNotNull(collaborativePlanning, "collaborativePlanning"); + this.collaborativePlanning = collaborativePlanning; + return this; + } + + /** + * Enables bigquery tool for the Deep Research agent. + */ + public DeepResearchAgentConfig withEnableBigqueryTool(boolean enableBigqueryTool) { + Utils.checkNotNull(enableBigqueryTool, "enableBigqueryTool"); + this.enableBigqueryTool = Optional.ofNullable(enableBigqueryTool); + return this; + } + + + /** + * Enables bigquery tool for the Deep Research agent. + */ + public DeepResearchAgentConfig withEnableBigqueryTool(Optional enableBigqueryTool) { + Utils.checkNotNull(enableBigqueryTool, "enableBigqueryTool"); + this.enableBigqueryTool = enableBigqueryTool; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeepResearchAgentConfig other = (DeepResearchAgentConfig) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.thinkingSummaries, other.thinkingSummaries) && + Utils.enhancedDeepEquals(this.visualization, other.visualization) && + Utils.enhancedDeepEquals(this.collaborativePlanning, other.collaborativePlanning) && + Utils.enhancedDeepEquals(this.enableBigqueryTool, other.enableBigqueryTool); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, thinkingSummaries, visualization, + collaborativePlanning, enableBigqueryTool); + } + + @Override + public String toString() { + return Utils.toString(DeepResearchAgentConfig.class, + "type", type, + "thinkingSummaries", thinkingSummaries, + "visualization", visualization, + "collaborativePlanning", collaborativePlanning, + "enableBigqueryTool", enableBigqueryTool); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional thinkingSummaries = Optional.empty(); + + private Optional visualization = Optional.empty(); + + private Optional collaborativePlanning = Optional.empty(); + + private Optional enableBigqueryTool = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder thinkingSummaries(ThinkingSummaries thinkingSummaries) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + this.thinkingSummaries = Optional.ofNullable(thinkingSummaries); + return this; + } + + public Builder thinkingSummaries(Optional thinkingSummaries) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + this.thinkingSummaries = thinkingSummaries; + return this; + } + + + /** + * Whether to include visualizations in the response. + */ + public Builder visualization(Visualization visualization) { + Utils.checkNotNull(visualization, "visualization"); + this.visualization = Optional.ofNullable(visualization); + return this; + } + + /** + * Whether to include visualizations in the response. + */ + public Builder visualization(Optional visualization) { + Utils.checkNotNull(visualization, "visualization"); + this.visualization = visualization; + return this; + } + + + /** + * Enables human-in-the-loop planning for the Deep Research agent. If set to + * true, the Deep Research agent will provide a research plan in its response. + * The agent will then proceed only if the user confirms the plan in the next + * turn. + */ + public Builder collaborativePlanning(boolean collaborativePlanning) { + Utils.checkNotNull(collaborativePlanning, "collaborativePlanning"); + this.collaborativePlanning = Optional.ofNullable(collaborativePlanning); + return this; + } + + /** + * Enables human-in-the-loop planning for the Deep Research agent. If set to + * true, the Deep Research agent will provide a research plan in its response. + * The agent will then proceed only if the user confirms the plan in the next + * turn. + */ + public Builder collaborativePlanning(Optional collaborativePlanning) { + Utils.checkNotNull(collaborativePlanning, "collaborativePlanning"); + this.collaborativePlanning = collaborativePlanning; + return this; + } + + + /** + * Enables bigquery tool for the Deep Research agent. + */ + public Builder enableBigqueryTool(boolean enableBigqueryTool) { + Utils.checkNotNull(enableBigqueryTool, "enableBigqueryTool"); + this.enableBigqueryTool = Optional.ofNullable(enableBigqueryTool); + return this; + } + + /** + * Enables bigquery tool for the Deep Research agent. + */ + public Builder enableBigqueryTool(Optional enableBigqueryTool) { + Utils.checkNotNull(enableBigqueryTool, "enableBigqueryTool"); + this.enableBigqueryTool = enableBigqueryTool; + return this; + } + + public DeepResearchAgentConfig build() { + + return new DeepResearchAgentConfig( + thinkingSummaries, visualization, collaborativePlanning, + enableBigqueryTool); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"deep-research\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Disabled.java b/src/main/java/com/google/genai/gaos/models/interactions/Disabled.java new file mode 100644 index 00000000000..b88724480f7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Disabled.java @@ -0,0 +1,56 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * Disabled + * + *

Turns all network off. + */ +@SuppressWarnings("all") +public enum Disabled { + DISABLED("disabled"); + + @JsonValue + private final String value; + + Disabled(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (Disabled o: Disabled.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/DisabledSafetyPolicy.java b/src/main/java/com/google/genai/gaos/models/interactions/DisabledSafetyPolicy.java new file mode 100644 index 00000000000..277be22b783 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/DisabledSafetyPolicy.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum DisabledSafetyPolicy { + FINANCIAL_TRANSACTIONS("financial_transactions"), + SENSITIVE_DATA_MODIFICATION("sensitive_data_modification"), + COMMUNICATION_TOOL("communication_tool"), + ACCOUNT_CREATION("account_creation"), + DATA_MODIFICATION("data_modification"), + USER_CONSENT_MANAGEMENT("user_consent_management"), + LEGAL_TERMS_AND_AGREEMENTS("legal_terms_and_agreements"); + + @JsonValue + private final String value; + + DisabledSafetyPolicy(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (DisabledSafetyPolicy o: DisabledSafetyPolicy.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/DocumentContent.java b/src/main/java/com/google/genai/gaos/models/interactions/DocumentContent.java new file mode 100644 index 00000000000..a2e4768d5e4 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/DocumentContent.java @@ -0,0 +1,292 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * DocumentContent + * + *

A document content block. + */ +@SuppressWarnings("all") +public class DocumentContent { + + @JsonProperty("type") + private String type; + + /** + * The document content. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("data") + private Optional data; + + /** + * The URI of the document. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + /** + * The mime type of the document. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + @JsonCreator + public DocumentContent( + @JsonProperty("data") Optional data, + @JsonProperty("uri") Optional uri, + @JsonProperty("mime_type") Optional mimeType) { + Utils.checkNotNull(data, "data"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(mimeType, "mimeType"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.data = data; + this.uri = uri; + this.mimeType = mimeType; + } + + public DocumentContent() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The document content. + */ + @JsonIgnore + public Optional data() { + return data; + } + + /** + * The URI of the document. + */ + @JsonIgnore + public Optional uri() { + return uri; + } + + /** + * The mime type of the document. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The document content. + */ + public DocumentContent withData(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + + /** + * The document content. + */ + public DocumentContent withData(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + /** + * The URI of the document. + */ + public DocumentContent withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + /** + * The URI of the document. + */ + public DocumentContent withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + /** + * The mime type of the document. + */ + public DocumentContent withMimeType(DocumentContentMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + /** + * The mime type of the document. + */ + public DocumentContent withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DocumentContent other = (DocumentContent) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, data, uri, + mimeType); + } + + @Override + public String toString() { + return Utils.toString(DocumentContent.class, + "type", type, + "data", data, + "uri", uri, + "mimeType", mimeType); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional data = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The document content. + */ + public Builder data(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + /** + * The document content. + */ + public Builder data(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + + /** + * The URI of the document. + */ + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + /** + * The URI of the document. + */ + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + /** + * The mime type of the document. + */ + public Builder mimeType(DocumentContentMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + /** + * The mime type of the document. + */ + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + public DocumentContent build() { + + return new DocumentContent( + data, uri, mimeType); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"document\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/DocumentContentMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/DocumentContentMimeType.java new file mode 100644 index 00000000000..05ea434325a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/DocumentContentMimeType.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * DocumentContentMimeType + * + *

The mime type of the document. + */ +@SuppressWarnings("all") +public enum DocumentContentMimeType { + APPLICATION_PDF("application/pdf"), + TEXT_CSV("text/csv"); + + @JsonValue + private final String value; + + DocumentContentMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (DocumentContentMimeType o: DocumentContentMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/DocumentDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/DocumentDelta.java new file mode 100644 index 00000000000..9d21bd767e7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/DocumentDelta.java @@ -0,0 +1,237 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class DocumentDelta { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("data") + private Optional data; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + @JsonCreator + public DocumentDelta( + @JsonProperty("data") Optional data, + @JsonProperty("uri") Optional uri, + @JsonProperty("mime_type") Optional mimeType) { + Utils.checkNotNull(data, "data"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(mimeType, "mimeType"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.data = data; + this.uri = uri; + this.mimeType = mimeType; + } + + public DocumentDelta() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public Optional data() { + return data; + } + + @JsonIgnore + public Optional uri() { + return uri; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + public static Builder builder() { + return new Builder(); + } + + + public DocumentDelta withData(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + + public DocumentDelta withData(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + public DocumentDelta withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + public DocumentDelta withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + public DocumentDelta withMimeType(DocumentDeltaMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + public DocumentDelta withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DocumentDelta other = (DocumentDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, data, uri, + mimeType); + } + + @Override + public String toString() { + return Utils.toString(DocumentDelta.class, + "type", type, + "data", data, + "uri", uri, + "mimeType", mimeType); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional data = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder data(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + public Builder data(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + public Builder mimeType(DocumentDeltaMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + public DocumentDelta build() { + + return new DocumentDelta( + data, uri, mimeType); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"document\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/DocumentDeltaMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/DocumentDeltaMimeType.java new file mode 100644 index 00000000000..299e45de210 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/DocumentDeltaMimeType.java @@ -0,0 +1,52 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum DocumentDeltaMimeType { + APPLICATION_PDF("application/pdf"), + TEXT_CSV("text/csv"); + + @JsonValue + private final String value; + + DocumentDeltaMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (DocumentDeltaMimeType o: DocumentDeltaMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/DynamicAgentConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/DynamicAgentConfig.java new file mode 100644 index 00000000000..7cbe514019b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/DynamicAgentConfig.java @@ -0,0 +1,151 @@ +/* +* 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.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.util.HashMap; +import java.util.Map; + +/** + * DynamicAgentConfig + * + *

Configuration for dynamic agents. + */ +@SuppressWarnings("all") +public class DynamicAgentConfig { + + @JsonProperty("type") + private String type; + + + @JsonIgnore + private Map additionalProperties; + + @JsonCreator + public DynamicAgentConfig() { + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.additionalProperties = new HashMap<>(); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonAnyGetter + public Map additionalProperties() { + return additionalProperties; + } + + public static Builder builder() { + return new Builder(); + } + + + @JsonAnySetter + public DynamicAgentConfig withAdditionalProperty(String key, Object value) { + // note that value can be null because of the way JsonAnySetter works + Utils.checkNotNull(key, "key"); + additionalProperties.put(key, value); + return this; + } + public DynamicAgentConfig withAdditionalProperties(Map additionalProperties) { + Utils.checkNotNull(additionalProperties, "additionalProperties"); + this.additionalProperties = additionalProperties; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DynamicAgentConfig other = (DynamicAgentConfig) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.additionalProperties, other.additionalProperties); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, additionalProperties); + } + + @Override + public String toString() { + return Utils.toString(DynamicAgentConfig.class, + "type", type, + "additionalProperties", additionalProperties); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Map additionalProperties = new HashMap<>(); + + private Builder() { + // force use of static builder() method + } + + public Builder additionalProperty(String key, Object value) { + Utils.checkNotNull(key, "key"); + // we could be strict about null values (force the user + // to pass `JsonNullable.of(null)`) but likely to be a bit + // annoying for additional properties building so we'll + // relax preconditions. + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + Utils.checkNotNull(additionalProperties, "additionalProperties"); + this.additionalProperties = additionalProperties; + return this; + } + + public DynamicAgentConfig build() { + + return new DynamicAgentConfig( + ) + .withAdditionalProperties(additionalProperties); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"dynamic\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Empty.java b/src/main/java/com/google/genai/gaos/models/interactions/Empty.java new file mode 100644 index 00000000000..1450545039c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Empty.java @@ -0,0 +1,85 @@ +/* +* 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.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + +/** + * Empty + * + *

A generic empty message that you can re-use to avoid defining duplicated + * empty messages in your APIs. A typical example is to use it as the request + * or the response type of an API method. For instance: + * + *

service Foo { + * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + * } + */ +@SuppressWarnings("all") +public class Empty { + @JsonCreator + public Empty() { + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ); + } + + @Override + public String toString() { + return Utils.toString(Empty.class); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public Empty build() { + + return new Empty( + ); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Environment.java b/src/main/java/com/google/genai/gaos/models/interactions/Environment.java new file mode 100644 index 00000000000..f84bbbc1e89 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Environment.java @@ -0,0 +1,216 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * Environment + * + *

Configuration for a custom environment. + */ +@SuppressWarnings("all") +public class Environment { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("sources") + private Optional> sources; + + /** + * Network configuration for the environment. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("network") + private Optional network; + + @JsonCreator + public Environment( + @JsonProperty("sources") Optional> sources, + @JsonProperty("network") Optional network) { + Utils.checkNotNull(sources, "sources"); + Utils.checkNotNull(network, "network"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.sources = sources; + this.network = network; + } + + public Environment() { + this(Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> sources() { + return (Optional>) sources; + } + + /** + * Network configuration for the environment. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional network() { + return (Optional) network; + } + + public static Builder builder() { + return new Builder(); + } + + + public Environment withSources(List sources) { + Utils.checkNotNull(sources, "sources"); + this.sources = Optional.ofNullable(sources); + return this; + } + + + public Environment withSources(Optional> sources) { + Utils.checkNotNull(sources, "sources"); + this.sources = sources; + return this; + } + + /** + * Network configuration for the environment. + */ + public Environment withNetwork(Network network) { + Utils.checkNotNull(network, "network"); + this.network = Optional.ofNullable(network); + return this; + } + + + /** + * Network configuration for the environment. + */ + public Environment withNetwork(Optional network) { + Utils.checkNotNull(network, "network"); + this.network = network; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Environment other = (Environment) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.sources, other.sources) && + Utils.enhancedDeepEquals(this.network, other.network); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, sources, network); + } + + @Override + public String toString() { + return Utils.toString(Environment.class, + "type", type, + "sources", sources, + "network", network); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> sources = Optional.empty(); + + private Optional network = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder sources(List sources) { + Utils.checkNotNull(sources, "sources"); + this.sources = Optional.ofNullable(sources); + return this; + } + + public Builder sources(Optional> sources) { + Utils.checkNotNull(sources, "sources"); + this.sources = sources; + return this; + } + + + /** + * Network configuration for the environment. + */ + public Builder network(Network network) { + Utils.checkNotNull(network, "network"); + this.network = Optional.ofNullable(network); + return this; + } + + /** + * Network configuration for the environment. + */ + public Builder network(Optional network) { + Utils.checkNotNull(network, "network"); + this.network = network; + return this; + } + + public Environment build() { + + return new Environment( + sources, network); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"remote\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/EnvironmentEnum.java b/src/main/java/com/google/genai/gaos/models/interactions/EnvironmentEnum.java new file mode 100644 index 00000000000..b9982d14e37 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/EnvironmentEnum.java @@ -0,0 +1,58 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * EnvironmentEnum + * + *

The environment being operated. + */ +@SuppressWarnings("all") +public enum EnvironmentEnum { + BROWSER("browser"), + MOBILE("mobile"), + DESKTOP("desktop"); + + @JsonValue + private final String value; + + EnvironmentEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (EnvironmentEnum o: EnvironmentEnum.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/EnvironmentNetworkEgressAllowlist.java b/src/main/java/com/google/genai/gaos/models/interactions/EnvironmentNetworkEgressAllowlist.java new file mode 100644 index 00000000000..249c775c845 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/EnvironmentNetworkEgressAllowlist.java @@ -0,0 +1,118 @@ +/* +* 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.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; + +/** + * EnvironmentNetworkEgressAllowlist + * + *

Outbound networking configuration for the sandbox. Accepts an object with an 'allowlist' array to + * restrict traffic, or the string 'disabled' to turn off all network access. Omit entirely to allow + * all outbound traffic with no header injection. + */ +@JsonDeserialize(using = EnvironmentNetworkEgressAllowlist._Deserializer.class) +@SuppressWarnings("all") +public class EnvironmentNetworkEgressAllowlist { + + @JsonValue + private final TypedObject value; + + private EnvironmentNetworkEgressAllowlist(TypedObject value) { + this.value = value; + } + + public static EnvironmentNetworkEgressAllowlist of(Allowlist value) { + Utils.checkNotNull(value, "value"); + return new EnvironmentNetworkEgressAllowlist(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static EnvironmentNetworkEgressAllowlist of(Disabled value) { + Utils.checkNotNull(value, "value"); + return new EnvironmentNetworkEgressAllowlist(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.Allowlist}
  • + *
  • {@code com.google.genai.gaos.models.interactions.Disabled}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnvironmentNetworkEgressAllowlist other = (EnvironmentNetworkEgressAllowlist) 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(EnvironmentNetworkEgressAllowlist.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(EnvironmentNetworkEgressAllowlist.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Error.java b/src/main/java/com/google/genai/gaos/models/interactions/Error.java new file mode 100644 index 00000000000..79aee577c1f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Error.java @@ -0,0 +1,209 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * Error + * + *

Error message from an interaction. + */ +@SuppressWarnings("all") +public class Error { + /** + * A URI that identifies the error type. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("code") + private Optional code; + + /** + * A human-readable error message. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("message") + private Optional message; + + @JsonCreator + public Error( + @JsonProperty("code") Optional code, + @JsonProperty("message") Optional message) { + Utils.checkNotNull(code, "code"); + Utils.checkNotNull(message, "message"); + this.code = code; + this.message = message; + } + + public Error() { + this(Optional.empty(), Optional.empty()); + } + + /** + * A URI that identifies the error type. + */ + @JsonIgnore + public Optional code() { + return code; + } + + /** + * A human-readable error message. + */ + @JsonIgnore + public Optional message() { + return message; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * A URI that identifies the error type. + */ + public Error withCode(String code) { + Utils.checkNotNull(code, "code"); + this.code = Optional.ofNullable(code); + return this; + } + + + /** + * A URI that identifies the error type. + */ + public Error withCode(Optional code) { + Utils.checkNotNull(code, "code"); + this.code = code; + return this; + } + + /** + * A human-readable error message. + */ + public Error withMessage(String message) { + Utils.checkNotNull(message, "message"); + this.message = Optional.ofNullable(message); + return this; + } + + + /** + * A human-readable error message. + */ + public Error withMessage(Optional message) { + Utils.checkNotNull(message, "message"); + this.message = message; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error other = (Error) o; + return + Utils.enhancedDeepEquals(this.code, other.code) && + Utils.enhancedDeepEquals(this.message, other.message); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + code, message); + } + + @Override + public String toString() { + return Utils.toString(Error.class, + "code", code, + "message", message); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional code = Optional.empty(); + + private Optional message = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * A URI that identifies the error type. + */ + public Builder code(String code) { + Utils.checkNotNull(code, "code"); + this.code = Optional.ofNullable(code); + return this; + } + + /** + * A URI that identifies the error type. + */ + public Builder code(Optional code) { + Utils.checkNotNull(code, "code"); + this.code = code; + return this; + } + + + /** + * A human-readable error message. + */ + public Builder message(String message) { + Utils.checkNotNull(message, "message"); + this.message = Optional.ofNullable(message); + return this; + } + + /** + * A human-readable error message. + */ + public Builder message(Optional message) { + Utils.checkNotNull(message, "message"); + this.message = message; + return this; + } + + public Error build() { + + return new Error( + code, message); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ErrorEvent.java b/src/main/java/com/google/genai/gaos/models/interactions/ErrorEvent.java new file mode 100644 index 00000000000..9a0f5488d60 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ErrorEvent.java @@ -0,0 +1,278 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ErrorEvent { + + @JsonProperty("event_type") + private String eventType; + + /** + * Error message from an interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("error") + private Optional error; + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("event_id") + private Optional eventId; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata") + private Optional metadata; + + @JsonCreator + public ErrorEvent( + @JsonProperty("error") Optional error, + @JsonProperty("event_id") Optional eventId, + @JsonProperty("metadata") Optional metadata) { + Utils.checkNotNull(error, "error"); + Utils.checkNotNull(eventId, "eventId"); + Utils.checkNotNull(metadata, "metadata"); + this.eventType = Builder._SINGLETON_VALUE_EventType.value(); + this.error = error; + this.eventId = eventId; + this.metadata = metadata; + } + + public ErrorEvent() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String eventType() { + return eventType; + } + + /** + * Error message from an interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional error() { + return (Optional) error; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonIgnore + public Optional eventId() { + return eventId; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional metadata() { + return (Optional) metadata; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Error message from an interaction. + */ + public ErrorEvent withError(Error error) { + Utils.checkNotNull(error, "error"); + this.error = Optional.ofNullable(error); + return this; + } + + + /** + * Error message from an interaction. + */ + public ErrorEvent withError(Optional error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public ErrorEvent withEventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public ErrorEvent withEventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + public ErrorEvent withMetadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + + public ErrorEvent withMetadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorEvent other = (ErrorEvent) o; + return + Utils.enhancedDeepEquals(this.eventType, other.eventType) && + Utils.enhancedDeepEquals(this.error, other.error) && + Utils.enhancedDeepEquals(this.eventId, other.eventId) && + Utils.enhancedDeepEquals(this.metadata, other.metadata); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + eventType, error, eventId, + metadata); + } + + @Override + public String toString() { + return Utils.toString(ErrorEvent.class, + "eventType", eventType, + "error", error, + "eventId", eventId, + "metadata", metadata); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional error = Optional.empty(); + + private Optional eventId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Error message from an interaction. + */ + public Builder error(Error error) { + Utils.checkNotNull(error, "error"); + this.error = Optional.ofNullable(error); + return this; + } + + /** + * Error message from an interaction. + */ + public Builder error(Optional error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + + public Builder metadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public Builder metadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + public ErrorEvent build() { + + return new ErrorEvent( + error, eventId, metadata); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_EventType = + new LazySingletonValue<>( + "event_type", + "\"error\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ExaAISearchConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/ExaAISearchConfig.java new file mode 100644 index 00000000000..32de49437c6 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ExaAISearchConfig.java @@ -0,0 +1,194 @@ +/* +* 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.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Map; +import java.util.Optional; + +/** + * ExaAISearchConfig + * + *

Used to specify configuration for ExaAISearch. + */ +@SuppressWarnings("all") +public class ExaAISearchConfig { + /** + * Required. The API key for ExaAiSearch. + */ + @JsonProperty("api_key") + private String apiKey; + + /** + * Optional. This field can be used to pass any parameter from the Exa.ai Search API. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("custom_config") + private Optional> customConfig; + + @JsonCreator + public ExaAISearchConfig( + @JsonProperty("api_key") String apiKey, + @JsonProperty("custom_config") Optional> customConfig) { + Utils.checkNotNull(apiKey, "apiKey"); + Utils.checkNotNull(customConfig, "customConfig"); + this.apiKey = apiKey; + this.customConfig = customConfig; + } + + public ExaAISearchConfig( + String apiKey) { + this(apiKey, Optional.empty()); + } + + /** + * Required. The API key for ExaAiSearch. + */ + @JsonIgnore + public String apiKey() { + return apiKey; + } + + /** + * Optional. This field can be used to pass any parameter from the Exa.ai Search API. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> customConfig() { + return (Optional>) customConfig; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. The API key for ExaAiSearch. + */ + public ExaAISearchConfig withApiKey(String apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = apiKey; + return this; + } + + /** + * Optional. This field can be used to pass any parameter from the Exa.ai Search API. + */ + public ExaAISearchConfig withCustomConfig(Map customConfig) { + Utils.checkNotNull(customConfig, "customConfig"); + this.customConfig = Optional.ofNullable(customConfig); + return this; + } + + + /** + * Optional. This field can be used to pass any parameter from the Exa.ai Search API. + */ + public ExaAISearchConfig withCustomConfig(Optional> customConfig) { + Utils.checkNotNull(customConfig, "customConfig"); + this.customConfig = customConfig; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExaAISearchConfig other = (ExaAISearchConfig) o; + return + Utils.enhancedDeepEquals(this.apiKey, other.apiKey) && + Utils.enhancedDeepEquals(this.customConfig, other.customConfig); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiKey, customConfig); + } + + @Override + public String toString() { + return Utils.toString(ExaAISearchConfig.class, + "apiKey", apiKey, + "customConfig", customConfig); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String apiKey; + + private Optional> customConfig = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. The API key for ExaAiSearch. + */ + public Builder apiKey(String apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = apiKey; + return this; + } + + + /** + * Optional. This field can be used to pass any parameter from the Exa.ai Search API. + */ + public Builder customConfig(Map customConfig) { + Utils.checkNotNull(customConfig, "customConfig"); + this.customConfig = Optional.ofNullable(customConfig); + return this; + } + + /** + * Optional. This field can be used to pass any parameter from the Exa.ai Search API. + */ + public Builder customConfig(Optional> customConfig) { + Utils.checkNotNull(customConfig, "customConfig"); + this.customConfig = customConfig; + return this; + } + + public ExaAISearchConfig build() { + + return new ExaAISearchConfig( + apiKey, customConfig); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FileCitation.java b/src/main/java/com/google/genai/gaos/models/interactions/FileCitation.java new file mode 100644 index 00000000000..eac87ef06c5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FileCitation.java @@ -0,0 +1,612 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Map; +import java.util.Optional; + +/** + * FileCitation + * + *

A file citation annotation. + */ +@SuppressWarnings("all") +public class FileCitation { + + @JsonProperty("type") + private String type; + + /** + * The URI of the file. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("document_uri") + private Optional documentUri; + + /** + * The name of the file. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("file_name") + private Optional fileName; + + /** + * Source attributed for a portion of the text. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("source") + private Optional source; + + /** + * User provided metadata about the retrieved context. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("custom_metadata") + private Optional> customMetadata; + + /** + * Page number of the cited document, if applicable. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("page_number") + private Optional pageNumber; + + /** + * Media ID in-case of image citations, if applicable. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("media_id") + private Optional mediaId; + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("start_index") + private Optional startIndex; + + /** + * End of the attributed segment, exclusive. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("end_index") + private Optional endIndex; + + @JsonCreator + public FileCitation( + @JsonProperty("document_uri") Optional documentUri, + @JsonProperty("file_name") Optional fileName, + @JsonProperty("source") Optional source, + @JsonProperty("custom_metadata") Optional> customMetadata, + @JsonProperty("page_number") Optional pageNumber, + @JsonProperty("media_id") Optional mediaId, + @JsonProperty("start_index") Optional startIndex, + @JsonProperty("end_index") Optional endIndex) { + Utils.checkNotNull(documentUri, "documentUri"); + Utils.checkNotNull(fileName, "fileName"); + Utils.checkNotNull(source, "source"); + Utils.checkNotNull(customMetadata, "customMetadata"); + Utils.checkNotNull(pageNumber, "pageNumber"); + Utils.checkNotNull(mediaId, "mediaId"); + Utils.checkNotNull(startIndex, "startIndex"); + Utils.checkNotNull(endIndex, "endIndex"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.documentUri = documentUri; + this.fileName = fileName; + this.source = source; + this.customMetadata = customMetadata; + this.pageNumber = pageNumber; + this.mediaId = mediaId; + this.startIndex = startIndex; + this.endIndex = endIndex; + } + + public FileCitation() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The URI of the file. + */ + @JsonIgnore + public Optional documentUri() { + return documentUri; + } + + /** + * The name of the file. + */ + @JsonIgnore + public Optional fileName() { + return fileName; + } + + /** + * Source attributed for a portion of the text. + */ + @JsonIgnore + public Optional source() { + return source; + } + + /** + * User provided metadata about the retrieved context. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> customMetadata() { + return (Optional>) customMetadata; + } + + /** + * Page number of the cited document, if applicable. + */ + @JsonIgnore + public Optional pageNumber() { + return pageNumber; + } + + /** + * Media ID in-case of image citations, if applicable. + */ + @JsonIgnore + public Optional mediaId() { + return mediaId; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + @JsonIgnore + public Optional startIndex() { + return startIndex; + } + + /** + * End of the attributed segment, exclusive. + */ + @JsonIgnore + public Optional endIndex() { + return endIndex; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The URI of the file. + */ + public FileCitation withDocumentUri(String documentUri) { + Utils.checkNotNull(documentUri, "documentUri"); + this.documentUri = Optional.ofNullable(documentUri); + return this; + } + + + /** + * The URI of the file. + */ + public FileCitation withDocumentUri(Optional documentUri) { + Utils.checkNotNull(documentUri, "documentUri"); + this.documentUri = documentUri; + return this; + } + + /** + * The name of the file. + */ + public FileCitation withFileName(String fileName) { + Utils.checkNotNull(fileName, "fileName"); + this.fileName = Optional.ofNullable(fileName); + return this; + } + + + /** + * The name of the file. + */ + public FileCitation withFileName(Optional fileName) { + Utils.checkNotNull(fileName, "fileName"); + this.fileName = fileName; + return this; + } + + /** + * Source attributed for a portion of the text. + */ + public FileCitation withSource(String source) { + Utils.checkNotNull(source, "source"); + this.source = Optional.ofNullable(source); + return this; + } + + + /** + * Source attributed for a portion of the text. + */ + public FileCitation withSource(Optional source) { + Utils.checkNotNull(source, "source"); + this.source = source; + return this; + } + + /** + * User provided metadata about the retrieved context. + */ + public FileCitation withCustomMetadata(Map customMetadata) { + Utils.checkNotNull(customMetadata, "customMetadata"); + this.customMetadata = Optional.ofNullable(customMetadata); + return this; + } + + + /** + * User provided metadata about the retrieved context. + */ + public FileCitation withCustomMetadata(Optional> customMetadata) { + Utils.checkNotNull(customMetadata, "customMetadata"); + this.customMetadata = customMetadata; + return this; + } + + /** + * Page number of the cited document, if applicable. + */ + public FileCitation withPageNumber(int pageNumber) { + Utils.checkNotNull(pageNumber, "pageNumber"); + this.pageNumber = Optional.ofNullable(pageNumber); + return this; + } + + + /** + * Page number of the cited document, if applicable. + */ + public FileCitation withPageNumber(Optional pageNumber) { + Utils.checkNotNull(pageNumber, "pageNumber"); + this.pageNumber = pageNumber; + return this; + } + + /** + * Media ID in-case of image citations, if applicable. + */ + public FileCitation withMediaId(String mediaId) { + Utils.checkNotNull(mediaId, "mediaId"); + this.mediaId = Optional.ofNullable(mediaId); + return this; + } + + + /** + * Media ID in-case of image citations, if applicable. + */ + public FileCitation withMediaId(Optional mediaId) { + Utils.checkNotNull(mediaId, "mediaId"); + this.mediaId = mediaId; + return this; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public FileCitation withStartIndex(int startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = Optional.ofNullable(startIndex); + return this; + } + + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public FileCitation withStartIndex(Optional startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = startIndex; + return this; + } + + /** + * End of the attributed segment, exclusive. + */ + public FileCitation withEndIndex(int endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = Optional.ofNullable(endIndex); + return this; + } + + + /** + * End of the attributed segment, exclusive. + */ + public FileCitation withEndIndex(Optional endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = endIndex; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileCitation other = (FileCitation) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.documentUri, other.documentUri) && + Utils.enhancedDeepEquals(this.fileName, other.fileName) && + Utils.enhancedDeepEquals(this.source, other.source) && + Utils.enhancedDeepEquals(this.customMetadata, other.customMetadata) && + Utils.enhancedDeepEquals(this.pageNumber, other.pageNumber) && + Utils.enhancedDeepEquals(this.mediaId, other.mediaId) && + Utils.enhancedDeepEquals(this.startIndex, other.startIndex) && + Utils.enhancedDeepEquals(this.endIndex, other.endIndex); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, documentUri, fileName, + source, customMetadata, pageNumber, + mediaId, startIndex, endIndex); + } + + @Override + public String toString() { + return Utils.toString(FileCitation.class, + "type", type, + "documentUri", documentUri, + "fileName", fileName, + "source", source, + "customMetadata", customMetadata, + "pageNumber", pageNumber, + "mediaId", mediaId, + "startIndex", startIndex, + "endIndex", endIndex); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional documentUri = Optional.empty(); + + private Optional fileName = Optional.empty(); + + private Optional source = Optional.empty(); + + private Optional> customMetadata = Optional.empty(); + + private Optional pageNumber = Optional.empty(); + + private Optional mediaId = Optional.empty(); + + private Optional startIndex = Optional.empty(); + + private Optional endIndex = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The URI of the file. + */ + public Builder documentUri(String documentUri) { + Utils.checkNotNull(documentUri, "documentUri"); + this.documentUri = Optional.ofNullable(documentUri); + return this; + } + + /** + * The URI of the file. + */ + public Builder documentUri(Optional documentUri) { + Utils.checkNotNull(documentUri, "documentUri"); + this.documentUri = documentUri; + return this; + } + + + /** + * The name of the file. + */ + public Builder fileName(String fileName) { + Utils.checkNotNull(fileName, "fileName"); + this.fileName = Optional.ofNullable(fileName); + return this; + } + + /** + * The name of the file. + */ + public Builder fileName(Optional fileName) { + Utils.checkNotNull(fileName, "fileName"); + this.fileName = fileName; + return this; + } + + + /** + * Source attributed for a portion of the text. + */ + public Builder source(String source) { + Utils.checkNotNull(source, "source"); + this.source = Optional.ofNullable(source); + return this; + } + + /** + * Source attributed for a portion of the text. + */ + public Builder source(Optional source) { + Utils.checkNotNull(source, "source"); + this.source = source; + return this; + } + + + /** + * User provided metadata about the retrieved context. + */ + public Builder customMetadata(Map customMetadata) { + Utils.checkNotNull(customMetadata, "customMetadata"); + this.customMetadata = Optional.ofNullable(customMetadata); + return this; + } + + /** + * User provided metadata about the retrieved context. + */ + public Builder customMetadata(Optional> customMetadata) { + Utils.checkNotNull(customMetadata, "customMetadata"); + this.customMetadata = customMetadata; + return this; + } + + + /** + * Page number of the cited document, if applicable. + */ + public Builder pageNumber(int pageNumber) { + Utils.checkNotNull(pageNumber, "pageNumber"); + this.pageNumber = Optional.ofNullable(pageNumber); + return this; + } + + /** + * Page number of the cited document, if applicable. + */ + public Builder pageNumber(Optional pageNumber) { + Utils.checkNotNull(pageNumber, "pageNumber"); + this.pageNumber = pageNumber; + return this; + } + + + /** + * Media ID in-case of image citations, if applicable. + */ + public Builder mediaId(String mediaId) { + Utils.checkNotNull(mediaId, "mediaId"); + this.mediaId = Optional.ofNullable(mediaId); + return this; + } + + /** + * Media ID in-case of image citations, if applicable. + */ + public Builder mediaId(Optional mediaId) { + Utils.checkNotNull(mediaId, "mediaId"); + this.mediaId = mediaId; + return this; + } + + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public Builder startIndex(int startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = Optional.ofNullable(startIndex); + return this; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public Builder startIndex(Optional startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = startIndex; + return this; + } + + + /** + * End of the attributed segment, exclusive. + */ + public Builder endIndex(int endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = Optional.ofNullable(endIndex); + return this; + } + + /** + * End of the attributed segment, exclusive. + */ + public Builder endIndex(Optional endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = endIndex; + return this; + } + + public FileCitation build() { + + return new FileCitation( + documentUri, fileName, source, + customMetadata, pageNumber, mediaId, + startIndex, endIndex); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"file_citation\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FileSearch.java b/src/main/java/com/google/genai/gaos/models/interactions/FileSearch.java new file mode 100644 index 00000000000..19683e9dbce --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FileSearch.java @@ -0,0 +1,294 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * FileSearch + * + *

A tool that can be used by the model to search files. + */ +@SuppressWarnings("all") +public class FileSearch { + + @JsonProperty("type") + private String type; + + /** + * The file search store names to search. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("file_search_store_names") + private Optional> fileSearchStoreNames; + + /** + * The number of semantic retrieval chunks to retrieve. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("top_k") + private Optional topK; + + /** + * Metadata filter to apply to the semantic retrieval documents and chunks. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata_filter") + private Optional metadataFilter; + + @JsonCreator + public FileSearch( + @JsonProperty("file_search_store_names") Optional> fileSearchStoreNames, + @JsonProperty("top_k") Optional topK, + @JsonProperty("metadata_filter") Optional metadataFilter) { + Utils.checkNotNull(fileSearchStoreNames, "fileSearchStoreNames"); + Utils.checkNotNull(topK, "topK"); + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.fileSearchStoreNames = fileSearchStoreNames; + this.topK = topK; + this.metadataFilter = metadataFilter; + } + + public FileSearch() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The file search store names to search. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> fileSearchStoreNames() { + return (Optional>) fileSearchStoreNames; + } + + /** + * The number of semantic retrieval chunks to retrieve. + */ + @JsonIgnore + public Optional topK() { + return topK; + } + + /** + * Metadata filter to apply to the semantic retrieval documents and chunks. + */ + @JsonIgnore + public Optional metadataFilter() { + return metadataFilter; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The file search store names to search. + */ + public FileSearch withFileSearchStoreNames(List fileSearchStoreNames) { + Utils.checkNotNull(fileSearchStoreNames, "fileSearchStoreNames"); + this.fileSearchStoreNames = Optional.ofNullable(fileSearchStoreNames); + return this; + } + + + /** + * The file search store names to search. + */ + public FileSearch withFileSearchStoreNames(Optional> fileSearchStoreNames) { + Utils.checkNotNull(fileSearchStoreNames, "fileSearchStoreNames"); + this.fileSearchStoreNames = fileSearchStoreNames; + return this; + } + + /** + * The number of semantic retrieval chunks to retrieve. + */ + public FileSearch withTopK(int topK) { + Utils.checkNotNull(topK, "topK"); + this.topK = Optional.ofNullable(topK); + return this; + } + + + /** + * The number of semantic retrieval chunks to retrieve. + */ + public FileSearch withTopK(Optional topK) { + Utils.checkNotNull(topK, "topK"); + this.topK = topK; + return this; + } + + /** + * Metadata filter to apply to the semantic retrieval documents and chunks. + */ + public FileSearch withMetadataFilter(String metadataFilter) { + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.metadataFilter = Optional.ofNullable(metadataFilter); + return this; + } + + + /** + * Metadata filter to apply to the semantic retrieval documents and chunks. + */ + public FileSearch withMetadataFilter(Optional metadataFilter) { + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.metadataFilter = metadataFilter; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSearch other = (FileSearch) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.fileSearchStoreNames, other.fileSearchStoreNames) && + Utils.enhancedDeepEquals(this.topK, other.topK) && + Utils.enhancedDeepEquals(this.metadataFilter, other.metadataFilter); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, fileSearchStoreNames, topK, + metadataFilter); + } + + @Override + public String toString() { + return Utils.toString(FileSearch.class, + "type", type, + "fileSearchStoreNames", fileSearchStoreNames, + "topK", topK, + "metadataFilter", metadataFilter); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> fileSearchStoreNames = Optional.empty(); + + private Optional topK = Optional.empty(); + + private Optional metadataFilter = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The file search store names to search. + */ + public Builder fileSearchStoreNames(List fileSearchStoreNames) { + Utils.checkNotNull(fileSearchStoreNames, "fileSearchStoreNames"); + this.fileSearchStoreNames = Optional.ofNullable(fileSearchStoreNames); + return this; + } + + /** + * The file search store names to search. + */ + public Builder fileSearchStoreNames(Optional> fileSearchStoreNames) { + Utils.checkNotNull(fileSearchStoreNames, "fileSearchStoreNames"); + this.fileSearchStoreNames = fileSearchStoreNames; + return this; + } + + + /** + * The number of semantic retrieval chunks to retrieve. + */ + public Builder topK(int topK) { + Utils.checkNotNull(topK, "topK"); + this.topK = Optional.ofNullable(topK); + return this; + } + + /** + * The number of semantic retrieval chunks to retrieve. + */ + public Builder topK(Optional topK) { + Utils.checkNotNull(topK, "topK"); + this.topK = topK; + return this; + } + + + /** + * Metadata filter to apply to the semantic retrieval documents and chunks. + */ + public Builder metadataFilter(String metadataFilter) { + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.metadataFilter = Optional.ofNullable(metadataFilter); + return this; + } + + /** + * Metadata filter to apply to the semantic retrieval documents and chunks. + */ + public Builder metadataFilter(Optional metadataFilter) { + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.metadataFilter = metadataFilter; + return this; + } + + public FileSearch build() { + + return new FileSearch( + fileSearchStoreNames, topK, metadataFilter); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"file_search\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FileSearchCallDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchCallDelta.java new file mode 100644 index 00000000000..9fdf0112621 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchCallDelta.java @@ -0,0 +1,165 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class FileSearchCallDelta { + + @JsonProperty("type") + private String type; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public FileSearchCallDelta( + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.signature = signature; + } + + public FileSearchCallDelta() { + this(Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * A signature hash for backend validation. + */ + public FileSearchCallDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public FileSearchCallDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSearchCallDelta other = (FileSearchCallDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, signature); + } + + @Override + public String toString() { + return Utils.toString(FileSearchCallDelta.class, + "type", type, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public FileSearchCallDelta build() { + + return new FileSearchCallDelta( + signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"file_search_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FileSearchCallStep.java b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchCallStep.java new file mode 100644 index 00000000000..59de5b0417e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchCallStep.java @@ -0,0 +1,210 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * FileSearchCallStep + * + *

File Search call step. + */ +@SuppressWarnings("all") +public class FileSearchCallStep { + + @JsonProperty("type") + private String type; + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonProperty("id") + private String id; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public FileSearchCallStep( + @JsonProperty("id") String id, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.id = id; + this.signature = signature; + } + + public FileSearchCallStep( + String id) { + this(id, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public FileSearchCallStep withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * A signature hash for backend validation. + */ + public FileSearchCallStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public FileSearchCallStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSearchCallStep other = (FileSearchCallStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, id, signature); + } + + @Override + public String toString() { + return Utils.toString(FileSearchCallStep.class, + "type", type, + "id", id, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String id; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public FileSearchCallStep build() { + + return new FileSearchCallStep( + id, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"file_search_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResult.java b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResult.java new file mode 100644 index 00000000000..dff8038531a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResult.java @@ -0,0 +1,79 @@ +/* +* 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.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + +/** + * FileSearchResult + * + *

The result of the File Search. + */ +@SuppressWarnings("all") +public class FileSearchResult { + @JsonCreator + public FileSearchResult() { + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ); + } + + @Override + public String toString() { + return Utils.toString(FileSearchResult.class); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public FileSearchResult build() { + + return new FileSearchResult( + ); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResultDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResultDelta.java new file mode 100644 index 00000000000..32e01876939 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResultDelta.java @@ -0,0 +1,196 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + + +@SuppressWarnings("all") +public class FileSearchResultDelta { + + @JsonProperty("type") + private String type; + + + @JsonProperty("result") + private List result; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public FileSearchResultDelta( + @JsonProperty("result") List result, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.signature = signature; + } + + public FileSearchResultDelta( + List result) { + this(result, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public List result() { + return result; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + public FileSearchResultDelta withResult(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + /** + * A signature hash for backend validation. + */ + public FileSearchResultDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public FileSearchResultDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSearchResultDelta other = (FileSearchResultDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, signature); + } + + @Override + public String toString() { + return Utils.toString(FileSearchResultDelta.class, + "type", type, + "result", result, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private List result; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder result(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public FileSearchResultDelta build() { + + return new FileSearchResultDelta( + result, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"file_search_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResultStep.java b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResultStep.java new file mode 100644 index 00000000000..f79ae2d43f4 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FileSearchResultStep.java @@ -0,0 +1,210 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * FileSearchResultStep + * + *

File Search result step. + */ +@SuppressWarnings("all") +public class FileSearchResultStep { + + @JsonProperty("type") + private String type; + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonProperty("call_id") + private String callId; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public FileSearchResultStep( + @JsonProperty("call_id") String callId, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(callId, "callId"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.callId = callId; + this.signature = signature; + } + + public FileSearchResultStep( + String callId) { + this(callId, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonIgnore + public String callId() { + return callId; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public FileSearchResultStep withCallId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + /** + * A signature hash for backend validation. + */ + public FileSearchResultStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public FileSearchResultStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileSearchResultStep other = (FileSearchResultStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.callId, other.callId) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, callId, signature); + } + + @Override + public String toString() { + return Utils.toString(FileSearchResultStep.class, + "type", type, + "callId", callId, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String callId; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public Builder callId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public FileSearchResultStep build() { + + return new FileSearchResultStep( + callId, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"file_search_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Filter.java b/src/main/java/com/google/genai/gaos/models/interactions/Filter.java new file mode 100644 index 00000000000..975bb15a9e6 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Filter.java @@ -0,0 +1,282 @@ +/* +* 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.JsonIgnore; +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 java.lang.Double; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * Filter + * + *

Config for filters. + */ +@SuppressWarnings("all") +public class Filter { + /** + * Optional. Only returns contexts with vector distance smaller than the + * threshold. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("vector_distance_threshold") + private Optional vectorDistanceThreshold; + + /** + * Optional. Only returns contexts with vector similarity larger than the + * threshold. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("vector_similarity_threshold") + private Optional vectorSimilarityThreshold; + + /** + * Optional. String for metadata filtering. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata_filter") + private Optional metadataFilter; + + @JsonCreator + public Filter( + @JsonProperty("vector_distance_threshold") Optional vectorDistanceThreshold, + @JsonProperty("vector_similarity_threshold") Optional vectorSimilarityThreshold, + @JsonProperty("metadata_filter") Optional metadataFilter) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + Utils.checkNotNull(vectorSimilarityThreshold, "vectorSimilarityThreshold"); + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.vectorDistanceThreshold = vectorDistanceThreshold; + this.vectorSimilarityThreshold = vectorSimilarityThreshold; + this.metadataFilter = metadataFilter; + } + + public Filter() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * Optional. Only returns contexts with vector distance smaller than the + * threshold. + */ + @JsonIgnore + public Optional vectorDistanceThreshold() { + return vectorDistanceThreshold; + } + + /** + * Optional. Only returns contexts with vector similarity larger than the + * threshold. + */ + @JsonIgnore + public Optional vectorSimilarityThreshold() { + return vectorSimilarityThreshold; + } + + /** + * Optional. String for metadata filtering. + */ + @JsonIgnore + public Optional metadataFilter() { + return metadataFilter; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. Only returns contexts with vector distance smaller than the + * threshold. + */ + public Filter withVectorDistanceThreshold(double vectorDistanceThreshold) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + this.vectorDistanceThreshold = Optional.ofNullable(vectorDistanceThreshold); + return this; + } + + + /** + * Optional. Only returns contexts with vector distance smaller than the + * threshold. + */ + public Filter withVectorDistanceThreshold(Optional vectorDistanceThreshold) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + this.vectorDistanceThreshold = vectorDistanceThreshold; + return this; + } + + /** + * Optional. Only returns contexts with vector similarity larger than the + * threshold. + */ + public Filter withVectorSimilarityThreshold(double vectorSimilarityThreshold) { + Utils.checkNotNull(vectorSimilarityThreshold, "vectorSimilarityThreshold"); + this.vectorSimilarityThreshold = Optional.ofNullable(vectorSimilarityThreshold); + return this; + } + + + /** + * Optional. Only returns contexts with vector similarity larger than the + * threshold. + */ + public Filter withVectorSimilarityThreshold(Optional vectorSimilarityThreshold) { + Utils.checkNotNull(vectorSimilarityThreshold, "vectorSimilarityThreshold"); + this.vectorSimilarityThreshold = vectorSimilarityThreshold; + return this; + } + + /** + * Optional. String for metadata filtering. + */ + public Filter withMetadataFilter(String metadataFilter) { + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.metadataFilter = Optional.ofNullable(metadataFilter); + return this; + } + + + /** + * Optional. String for metadata filtering. + */ + public Filter withMetadataFilter(Optional metadataFilter) { + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.metadataFilter = metadataFilter; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Filter other = (Filter) o; + return + Utils.enhancedDeepEquals(this.vectorDistanceThreshold, other.vectorDistanceThreshold) && + Utils.enhancedDeepEquals(this.vectorSimilarityThreshold, other.vectorSimilarityThreshold) && + Utils.enhancedDeepEquals(this.metadataFilter, other.metadataFilter); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + vectorDistanceThreshold, vectorSimilarityThreshold, metadataFilter); + } + + @Override + public String toString() { + return Utils.toString(Filter.class, + "vectorDistanceThreshold", vectorDistanceThreshold, + "vectorSimilarityThreshold", vectorSimilarityThreshold, + "metadataFilter", metadataFilter); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional vectorDistanceThreshold = Optional.empty(); + + private Optional vectorSimilarityThreshold = Optional.empty(); + + private Optional metadataFilter = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. Only returns contexts with vector distance smaller than the + * threshold. + */ + public Builder vectorDistanceThreshold(double vectorDistanceThreshold) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + this.vectorDistanceThreshold = Optional.ofNullable(vectorDistanceThreshold); + return this; + } + + /** + * Optional. Only returns contexts with vector distance smaller than the + * threshold. + */ + public Builder vectorDistanceThreshold(Optional vectorDistanceThreshold) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + this.vectorDistanceThreshold = vectorDistanceThreshold; + return this; + } + + + /** + * Optional. Only returns contexts with vector similarity larger than the + * threshold. + */ + public Builder vectorSimilarityThreshold(double vectorSimilarityThreshold) { + Utils.checkNotNull(vectorSimilarityThreshold, "vectorSimilarityThreshold"); + this.vectorSimilarityThreshold = Optional.ofNullable(vectorSimilarityThreshold); + return this; + } + + /** + * Optional. Only returns contexts with vector similarity larger than the + * threshold. + */ + public Builder vectorSimilarityThreshold(Optional vectorSimilarityThreshold) { + Utils.checkNotNull(vectorSimilarityThreshold, "vectorSimilarityThreshold"); + this.vectorSimilarityThreshold = vectorSimilarityThreshold; + return this; + } + + + /** + * Optional. String for metadata filtering. + */ + public Builder metadataFilter(String metadataFilter) { + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.metadataFilter = Optional.ofNullable(metadataFilter); + return this; + } + + /** + * Optional. String for metadata filtering. + */ + public Builder metadataFilter(Optional metadataFilter) { + Utils.checkNotNull(metadataFilter, "metadataFilter"); + this.metadataFilter = metadataFilter; + return this; + } + + public Filter build() { + + return new Filter( + vectorDistanceThreshold, vectorSimilarityThreshold, metadataFilter); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Function.java b/src/main/java/com/google/genai/gaos/models/interactions/Function.java new file mode 100644 index 00000000000..7b62a70ff82 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Function.java @@ -0,0 +1,293 @@ +/* +* 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.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * Function + * + *

A tool that can be used by the model. + */ +@SuppressWarnings("all") +public class Function { + + @JsonProperty("type") + private String type; + + /** + * The name of the function. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + /** + * A description of the function. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("description") + private Optional description; + + /** + * The JSON Schema for the function's parameters. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("parameters") + private Optional parameters; + + @JsonCreator + public Function( + @JsonProperty("name") Optional name, + @JsonProperty("description") Optional description, + @JsonProperty("parameters") Optional parameters) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(description, "description"); + Utils.checkNotNull(parameters, "parameters"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.description = description; + this.parameters = parameters; + } + + public Function() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The name of the function. + */ + @JsonIgnore + public Optional name() { + return name; + } + + /** + * A description of the function. + */ + @JsonIgnore + public Optional description() { + return description; + } + + /** + * The JSON Schema for the function's parameters. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional parameters() { + return (Optional) parameters; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The name of the function. + */ + public Function withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + /** + * The name of the function. + */ + public Function withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * A description of the function. + */ + public Function withDescription(String description) { + Utils.checkNotNull(description, "description"); + this.description = Optional.ofNullable(description); + return this; + } + + + /** + * A description of the function. + */ + public Function withDescription(Optional description) { + Utils.checkNotNull(description, "description"); + this.description = description; + return this; + } + + /** + * The JSON Schema for the function's parameters. + */ + public Function withParameters(Object parameters) { + Utils.checkNotNull(parameters, "parameters"); + this.parameters = Optional.ofNullable(parameters); + return this; + } + + + /** + * The JSON Schema for the function's parameters. + */ + public Function withParameters(Optional parameters) { + Utils.checkNotNull(parameters, "parameters"); + this.parameters = parameters; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Function other = (Function) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.description, other.description) && + Utils.enhancedDeepEquals(this.parameters, other.parameters); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, description, + parameters); + } + + @Override + public String toString() { + return Utils.toString(Function.class, + "type", type, + "name", name, + "description", description, + "parameters", parameters); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional name = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional parameters = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The name of the function. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + /** + * The name of the function. + */ + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * A description of the function. + */ + public Builder description(String description) { + Utils.checkNotNull(description, "description"); + this.description = Optional.ofNullable(description); + return this; + } + + /** + * A description of the function. + */ + public Builder description(Optional description) { + Utils.checkNotNull(description, "description"); + this.description = description; + return this; + } + + + /** + * The JSON Schema for the function's parameters. + */ + public Builder parameters(Object parameters) { + Utils.checkNotNull(parameters, "parameters"); + this.parameters = Optional.ofNullable(parameters); + return this; + } + + /** + * The JSON Schema for the function's parameters. + */ + public Builder parameters(Optional parameters) { + Utils.checkNotNull(parameters, "parameters"); + this.parameters = parameters; + return this; + } + + public Function build() { + + return new Function( + name, description, parameters); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"function\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FunctionCallStep.java b/src/main/java/com/google/genai/gaos/models/interactions/FunctionCallStep.java new file mode 100644 index 00000000000..92178f96626 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FunctionCallStep.java @@ -0,0 +1,226 @@ +/* +* 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.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.util.Map; + +/** + * FunctionCallStep + * + *

A function tool call step. + */ +@SuppressWarnings("all") +public class FunctionCallStep { + + @JsonProperty("type") + private String type; + + /** + * Required. The name of the tool to call. + */ + @JsonProperty("name") + private String name; + + /** + * Required. The arguments to pass to the function. + */ + @JsonProperty("arguments") + private Map arguments; + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonProperty("id") + private String id; + + @JsonCreator + public FunctionCallStep( + @JsonProperty("name") String name, + @JsonProperty("arguments") Map arguments, + @JsonProperty("id") String id) { + Utils.checkNotNull(name, "name"); + arguments = Utils.emptyMapIfNull(arguments); + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(id, "id"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.arguments = arguments; + this.id = id; + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. The name of the tool to call. + */ + @JsonIgnore + public String name() { + return name; + } + + /** + * Required. The arguments to pass to the function. + */ + @JsonIgnore + public Map arguments() { + return arguments; + } + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonIgnore + public String id() { + return id; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. The name of the tool to call. + */ + public FunctionCallStep withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * Required. The arguments to pass to the function. + */ + public FunctionCallStep withArguments(Map arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * Required. A unique ID for this specific tool call. + */ + public FunctionCallStep withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionCallStep other = (FunctionCallStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.id, other.id); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, arguments, + id); + } + + @Override + public String toString() { + return Utils.toString(FunctionCallStep.class, + "type", type, + "name", name, + "arguments", arguments, + "id", id); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String name; + + private Map arguments; + + private String id; + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. The name of the tool to call. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * Required. The arguments to pass to the function. + */ + public Builder arguments(Map arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public FunctionCallStep build() { + + return new FunctionCallStep( + name, arguments, id); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"function_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDelta.java new file mode 100644 index 00000000000..b85323e7041 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDelta.java @@ -0,0 +1,266 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class FunctionResultDelta { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("is_error") + private Optional isError; + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonProperty("call_id") + private String callId; + + + @JsonProperty("result") + private FunctionResultDeltaResultUnion result; + + @JsonCreator + public FunctionResultDelta( + @JsonProperty("name") Optional name, + @JsonProperty("is_error") Optional isError, + @JsonProperty("call_id") String callId, + @JsonProperty("result") FunctionResultDeltaResultUnion result) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(isError, "isError"); + Utils.checkNotNull(callId, "callId"); + Utils.checkNotNull(result, "result"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.isError = isError; + this.callId = callId; + this.result = result; + } + + public FunctionResultDelta( + String callId, + FunctionResultDeltaResultUnion result) { + this(Optional.empty(), Optional.empty(), callId, + result); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public Optional name() { + return name; + } + + @JsonIgnore + public Optional isError() { + return isError; + } + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonIgnore + public String callId() { + return callId; + } + + @JsonIgnore + public FunctionResultDeltaResultUnion result() { + return result; + } + + public static Builder builder() { + return new Builder(); + } + + + public FunctionResultDelta withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + public FunctionResultDelta withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + public FunctionResultDelta withIsError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + + public FunctionResultDelta withIsError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + /** + * Required. ID to match the ID from the function call block. + */ + public FunctionResultDelta withCallId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + public FunctionResultDelta withResult(FunctionResultDeltaResultUnion result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionResultDelta other = (FunctionResultDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.isError, other.isError) && + Utils.enhancedDeepEquals(this.callId, other.callId) && + Utils.enhancedDeepEquals(this.result, other.result); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, isError, + callId, result); + } + + @Override + public String toString() { + return Utils.toString(FunctionResultDelta.class, + "type", type, + "name", name, + "isError", isError, + "callId", callId, + "result", result); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional name = Optional.empty(); + + private Optional isError = Optional.empty(); + + private String callId; + + private FunctionResultDeltaResultUnion result; + + private Builder() { + // force use of static builder() method + } + + + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + public Builder isError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + public Builder isError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public Builder callId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + + public Builder result(FunctionResultDeltaResultUnion result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + public FunctionResultDelta build() { + + return new FunctionResultDelta( + name, isError, callId, + result); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"function_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDeltaResult.java b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDeltaResult.java new file mode 100644 index 00000000000..f2554d15c8c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDeltaResult.java @@ -0,0 +1,75 @@ +/* +* 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.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + + +@SuppressWarnings("all") +public class FunctionResultDeltaResult { + @JsonCreator + public FunctionResultDeltaResult() { + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ); + } + + @Override + public String toString() { + return Utils.toString(FunctionResultDeltaResult.class); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public FunctionResultDeltaResult build() { + + return new FunctionResultDeltaResult( + ); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDeltaResultUnion.java b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDeltaResultUnion.java new file mode 100644 index 00000000000..2a763031369 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultDeltaResultUnion.java @@ -0,0 +1,119 @@ +/* +* 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.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.List; + +@JsonDeserialize(using = FunctionResultDeltaResultUnion._Deserializer.class) +@SuppressWarnings("all") +public class FunctionResultDeltaResultUnion { + + @JsonValue + private final TypedObject value; + + private FunctionResultDeltaResultUnion(TypedObject value) { + this.value = value; + } + + public static FunctionResultDeltaResultUnion of(FunctionResultDeltaResult value) { + Utils.checkNotNull(value, "value"); + return new FunctionResultDeltaResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static FunctionResultDeltaResultUnion of(List value) { + Utils.checkNotNull(value, "value"); + return new FunctionResultDeltaResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static FunctionResultDeltaResultUnion of(String value) { + Utils.checkNotNull(value, "value"); + return new FunctionResultDeltaResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.FunctionResultDeltaResult}
  • + *
  • {@code java.util.List}
  • + *
  • {@code java.lang.String}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionResultDeltaResultUnion other = (FunctionResultDeltaResultUnion) 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(FunctionResultDeltaResultUnion.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(FunctionResultDeltaResultUnion.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStep.java b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStep.java new file mode 100644 index 00000000000..4901e1b1662 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStep.java @@ -0,0 +1,315 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * FunctionResultStep + * + *

Result of a function tool call. + */ +@SuppressWarnings("all") +public class FunctionResultStep { + + @JsonProperty("type") + private String type; + + /** + * The name of the tool that was called. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + /** + * Whether the tool call resulted in an error. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("is_error") + private Optional isError; + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonProperty("call_id") + private String callId; + + /** + * The result of the tool call. + */ + @JsonProperty("result") + private FunctionResultStepResultUnion result; + + @JsonCreator + public FunctionResultStep( + @JsonProperty("name") Optional name, + @JsonProperty("is_error") Optional isError, + @JsonProperty("call_id") String callId, + @JsonProperty("result") FunctionResultStepResultUnion result) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(isError, "isError"); + Utils.checkNotNull(callId, "callId"); + Utils.checkNotNull(result, "result"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.isError = isError; + this.callId = callId; + this.result = result; + } + + public FunctionResultStep( + String callId, + FunctionResultStepResultUnion result) { + this(Optional.empty(), Optional.empty(), callId, + result); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The name of the tool that was called. + */ + @JsonIgnore + public Optional name() { + return name; + } + + /** + * Whether the tool call resulted in an error. + */ + @JsonIgnore + public Optional isError() { + return isError; + } + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonIgnore + public String callId() { + return callId; + } + + /** + * The result of the tool call. + */ + @JsonIgnore + public FunctionResultStepResultUnion result() { + return result; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The name of the tool that was called. + */ + public FunctionResultStep withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + /** + * The name of the tool that was called. + */ + public FunctionResultStep withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * Whether the tool call resulted in an error. + */ + public FunctionResultStep withIsError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + + /** + * Whether the tool call resulted in an error. + */ + public FunctionResultStep withIsError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + /** + * Required. ID to match the ID from the function call block. + */ + public FunctionResultStep withCallId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + /** + * The result of the tool call. + */ + public FunctionResultStep withResult(FunctionResultStepResultUnion result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionResultStep other = (FunctionResultStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.isError, other.isError) && + Utils.enhancedDeepEquals(this.callId, other.callId) && + Utils.enhancedDeepEquals(this.result, other.result); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, isError, + callId, result); + } + + @Override + public String toString() { + return Utils.toString(FunctionResultStep.class, + "type", type, + "name", name, + "isError", isError, + "callId", callId, + "result", result); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional name = Optional.empty(); + + private Optional isError = Optional.empty(); + + private String callId; + + private FunctionResultStepResultUnion result; + + private Builder() { + // force use of static builder() method + } + + + /** + * The name of the tool that was called. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + /** + * The name of the tool that was called. + */ + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * Whether the tool call resulted in an error. + */ + public Builder isError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + /** + * Whether the tool call resulted in an error. + */ + public Builder isError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public Builder callId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + + /** + * The result of the tool call. + */ + public Builder result(FunctionResultStepResultUnion result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + public FunctionResultStep build() { + + return new FunctionResultStep( + name, isError, callId, + result); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"function_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStepResult.java b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStepResult.java new file mode 100644 index 00000000000..5144cfed71c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStepResult.java @@ -0,0 +1,75 @@ +/* +* 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.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + + +@SuppressWarnings("all") +public class FunctionResultStepResult { + @JsonCreator + public FunctionResultStepResult() { + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ); + } + + @Override + public String toString() { + return Utils.toString(FunctionResultStepResult.class); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public FunctionResultStepResult build() { + + return new FunctionResultStepResult( + ); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStepResultUnion.java b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStepResultUnion.java new file mode 100644 index 00000000000..35241b43257 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultStepResultUnion.java @@ -0,0 +1,124 @@ +/* +* 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.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.List; + +/** + * FunctionResultStepResultUnion + * + *

The result of the tool call. + */ +@JsonDeserialize(using = FunctionResultStepResultUnion._Deserializer.class) +@SuppressWarnings("all") +public class FunctionResultStepResultUnion { + + @JsonValue + private final TypedObject value; + + private FunctionResultStepResultUnion(TypedObject value) { + this.value = value; + } + + public static FunctionResultStepResultUnion of(FunctionResultStepResult value) { + Utils.checkNotNull(value, "value"); + return new FunctionResultStepResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static FunctionResultStepResultUnion of(List value) { + Utils.checkNotNull(value, "value"); + return new FunctionResultStepResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static FunctionResultStepResultUnion of(String value) { + Utils.checkNotNull(value, "value"); + return new FunctionResultStepResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.FunctionResultStepResult}
  • + *
  • {@code java.util.List}
  • + *
  • {@code java.lang.String}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionResultStepResultUnion other = (FunctionResultStepResultUnion) 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(FunctionResultStepResultUnion.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(FunctionResultStepResultUnion.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultSubcontent.java b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultSubcontent.java new file mode 100644 index 00000000000..ff85de2c909 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/FunctionResultSubcontent.java @@ -0,0 +1,111 @@ +/* +* 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.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; + +@JsonDeserialize(using = FunctionResultSubcontent._Deserializer.class) +@SuppressWarnings("all") +public class FunctionResultSubcontent { + + @JsonValue + private final TypedObject value; + + private FunctionResultSubcontent(TypedObject value) { + this.value = value; + } + + public static FunctionResultSubcontent of(TextContent value) { + Utils.checkNotNull(value, "value"); + return new FunctionResultSubcontent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static FunctionResultSubcontent of(ImageContent value) { + Utils.checkNotNull(value, "value"); + return new FunctionResultSubcontent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *
    + *
  • {@code com.google.genai.gaos.models.interactions.TextContent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ImageContent}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FunctionResultSubcontent other = (FunctionResultSubcontent) 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(FunctionResultSubcontent.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(FunctionResultSubcontent.class, + "value", value); + } + +} + 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 new file mode 100644 index 00000000000..e7d02297cf6 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GenerationConfig.java @@ -0,0 +1,902 @@ +/* +* 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.JsonIgnore; +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 java.lang.Deprecated; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * GenerationConfig + * + *

Configuration parameters for model interactions. + */ +@SuppressWarnings("all") +public class GenerationConfig { + /** + * Controls the randomness of the output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("temperature") + private Optional temperature; + + /** + * The maximum cumulative probability of tokens to consider when sampling. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("top_p") + private Optional topP; + + /** + * Seed used in decoding for reproducibility. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("seed") + private Optional seed; + + /** + * A list of character sequences that will stop output interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("stop_sequences") + private Optional> stopSequences; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("thinking_level") + private Optional thinkingLevel; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("thinking_summaries") + private Optional thinkingSummaries; + + /** + * The maximum number of tokens to include in the response. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("max_output_tokens") + private Optional maxOutputTokens; + + /** + * Configuration for speech interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("speech_config") + private Optional> speechConfig; + + /** + * The configuration for image interaction. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("image_config") + @Deprecated + private Optional imageConfig; + + /** + * Configuration options for video generation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("video_config") + private Optional videoConfig; + + /** + * Penalizes tokens that have already appeared in the generated + * text. A positive value encourages the model to generate more diverse and + * less repetitive text. Valid values can range from [-2.0, 2.0]. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("presence_penalty") + private Optional presencePenalty; + + /** + * Penalizes tokens based on their frequency in the generated text. + * A positive value helps to reduce the repetition of words and phrases. + * Valid values can range from [-2.0, 2.0]. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("frequency_penalty") + private Optional frequencyPenalty; + + /** + * The tool choice configuration. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("tool_choice") + private Optional toolChoice; + + @JsonCreator + public GenerationConfig( + @JsonProperty("temperature") Optional temperature, + @JsonProperty("top_p") Optional topP, + @JsonProperty("seed") Optional seed, + @JsonProperty("stop_sequences") Optional> stopSequences, + @JsonProperty("thinking_level") Optional thinkingLevel, + @JsonProperty("thinking_summaries") Optional thinkingSummaries, + @JsonProperty("max_output_tokens") Optional maxOutputTokens, + @JsonProperty("speech_config") Optional> speechConfig, + @JsonProperty("image_config") Optional imageConfig, + @JsonProperty("video_config") Optional videoConfig, + @JsonProperty("presence_penalty") Optional presencePenalty, + @JsonProperty("frequency_penalty") Optional frequencyPenalty, + @JsonProperty("tool_choice") Optional toolChoice) { + Utils.checkNotNull(temperature, "temperature"); + Utils.checkNotNull(topP, "topP"); + Utils.checkNotNull(seed, "seed"); + Utils.checkNotNull(stopSequences, "stopSequences"); + Utils.checkNotNull(thinkingLevel, "thinkingLevel"); + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + Utils.checkNotNull(maxOutputTokens, "maxOutputTokens"); + Utils.checkNotNull(speechConfig, "speechConfig"); + Utils.checkNotNull(imageConfig, "imageConfig"); + Utils.checkNotNull(videoConfig, "videoConfig"); + Utils.checkNotNull(presencePenalty, "presencePenalty"); + Utils.checkNotNull(frequencyPenalty, "frequencyPenalty"); + Utils.checkNotNull(toolChoice, "toolChoice"); + this.temperature = temperature; + this.topP = topP; + this.seed = seed; + this.stopSequences = stopSequences; + this.thinkingLevel = thinkingLevel; + this.thinkingSummaries = thinkingSummaries; + this.maxOutputTokens = maxOutputTokens; + this.speechConfig = speechConfig; + this.imageConfig = imageConfig; + this.videoConfig = videoConfig; + this.presencePenalty = presencePenalty; + this.frequencyPenalty = frequencyPenalty; + this.toolChoice = toolChoice; + } + + public GenerationConfig() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + /** + * Controls the randomness of the output. + */ + @JsonIgnore + public Optional temperature() { + return temperature; + } + + /** + * The maximum cumulative probability of tokens to consider when sampling. + */ + @JsonIgnore + public Optional topP() { + return topP; + } + + /** + * Seed used in decoding for reproducibility. + */ + @JsonIgnore + public Optional seed() { + return seed; + } + + /** + * A list of character sequences that will stop output interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> stopSequences() { + return (Optional>) stopSequences; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional thinkingLevel() { + return (Optional) thinkingLevel; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional thinkingSummaries() { + return (Optional) thinkingSummaries; + } + + /** + * The maximum number of tokens to include in the response. + */ + @JsonIgnore + public Optional maxOutputTokens() { + return maxOutputTokens; + } + + /** + * Configuration for speech interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> speechConfig() { + return (Optional>) speechConfig; + } + + /** + * The configuration for image interaction. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional imageConfig() { + return (Optional) imageConfig; + } + + /** + * Configuration options for video generation. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional videoConfig() { + return (Optional) videoConfig; + } + + /** + * Penalizes tokens that have already appeared in the generated + * text. A positive value encourages the model to generate more diverse and + * less repetitive text. Valid values can range from [-2.0, 2.0]. + */ + @JsonIgnore + public Optional presencePenalty() { + return presencePenalty; + } + + /** + * Penalizes tokens based on their frequency in the generated text. + * A positive value helps to reduce the repetition of words and phrases. + * Valid values can range from [-2.0, 2.0]. + */ + @JsonIgnore + public Optional frequencyPenalty() { + return frequencyPenalty; + } + + /** + * The tool choice configuration. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional toolChoice() { + return (Optional) toolChoice; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Controls the randomness of the output. + */ + public GenerationConfig withTemperature(float temperature) { + Utils.checkNotNull(temperature, "temperature"); + this.temperature = Optional.ofNullable(temperature); + return this; + } + + + /** + * Controls the randomness of the output. + */ + public GenerationConfig withTemperature(Optional temperature) { + Utils.checkNotNull(temperature, "temperature"); + this.temperature = temperature; + return this; + } + + /** + * The maximum cumulative probability of tokens to consider when sampling. + */ + public GenerationConfig withTopP(float topP) { + Utils.checkNotNull(topP, "topP"); + this.topP = Optional.ofNullable(topP); + return this; + } + + + /** + * The maximum cumulative probability of tokens to consider when sampling. + */ + public GenerationConfig withTopP(Optional topP) { + Utils.checkNotNull(topP, "topP"); + this.topP = topP; + return this; + } + + /** + * Seed used in decoding for reproducibility. + */ + public GenerationConfig withSeed(int seed) { + Utils.checkNotNull(seed, "seed"); + this.seed = Optional.ofNullable(seed); + return this; + } + + + /** + * Seed used in decoding for reproducibility. + */ + public GenerationConfig withSeed(Optional seed) { + Utils.checkNotNull(seed, "seed"); + this.seed = seed; + return this; + } + + /** + * A list of character sequences that will stop output interaction. + */ + public GenerationConfig withStopSequences(List stopSequences) { + Utils.checkNotNull(stopSequences, "stopSequences"); + this.stopSequences = Optional.ofNullable(stopSequences); + return this; + } + + + /** + * A list of character sequences that will stop output interaction. + */ + public GenerationConfig withStopSequences(Optional> stopSequences) { + Utils.checkNotNull(stopSequences, "stopSequences"); + this.stopSequences = stopSequences; + return this; + } + + public GenerationConfig withThinkingLevel(ThinkingLevel thinkingLevel) { + Utils.checkNotNull(thinkingLevel, "thinkingLevel"); + this.thinkingLevel = Optional.ofNullable(thinkingLevel); + return this; + } + + + public GenerationConfig withThinkingLevel(Optional thinkingLevel) { + Utils.checkNotNull(thinkingLevel, "thinkingLevel"); + this.thinkingLevel = thinkingLevel; + return this; + } + + public GenerationConfig withThinkingSummaries(ThinkingSummaries thinkingSummaries) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + this.thinkingSummaries = Optional.ofNullable(thinkingSummaries); + return this; + } + + + public GenerationConfig withThinkingSummaries(Optional thinkingSummaries) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + this.thinkingSummaries = thinkingSummaries; + return this; + } + + /** + * The maximum number of tokens to include in the response. + */ + public GenerationConfig withMaxOutputTokens(int maxOutputTokens) { + Utils.checkNotNull(maxOutputTokens, "maxOutputTokens"); + this.maxOutputTokens = Optional.ofNullable(maxOutputTokens); + return this; + } + + + /** + * The maximum number of tokens to include in the response. + */ + public GenerationConfig withMaxOutputTokens(Optional maxOutputTokens) { + Utils.checkNotNull(maxOutputTokens, "maxOutputTokens"); + this.maxOutputTokens = maxOutputTokens; + return this; + } + + /** + * Configuration for speech interaction. + */ + public GenerationConfig withSpeechConfig(List speechConfig) { + Utils.checkNotNull(speechConfig, "speechConfig"); + this.speechConfig = Optional.ofNullable(speechConfig); + return this; + } + + + /** + * Configuration for speech interaction. + */ + public GenerationConfig withSpeechConfig(Optional> speechConfig) { + Utils.checkNotNull(speechConfig, "speechConfig"); + this.speechConfig = speechConfig; + return this; + } + + /** + * The configuration for image interaction. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public GenerationConfig withImageConfig(ImageConfig imageConfig) { + Utils.checkNotNull(imageConfig, "imageConfig"); + this.imageConfig = Optional.ofNullable(imageConfig); + return this; + } + + + /** + * The configuration for image interaction. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public GenerationConfig withImageConfig(Optional imageConfig) { + Utils.checkNotNull(imageConfig, "imageConfig"); + this.imageConfig = imageConfig; + return this; + } + + /** + * Configuration options for video generation. + */ + public GenerationConfig withVideoConfig(VideoConfig videoConfig) { + Utils.checkNotNull(videoConfig, "videoConfig"); + this.videoConfig = Optional.ofNullable(videoConfig); + return this; + } + + + /** + * Configuration options for video generation. + */ + public GenerationConfig withVideoConfig(Optional videoConfig) { + Utils.checkNotNull(videoConfig, "videoConfig"); + this.videoConfig = videoConfig; + return this; + } + + /** + * Penalizes tokens that have already appeared in the generated + * text. A positive value encourages the model to generate more diverse and + * less repetitive text. Valid values can range from [-2.0, 2.0]. + */ + public GenerationConfig withPresencePenalty(float presencePenalty) { + Utils.checkNotNull(presencePenalty, "presencePenalty"); + this.presencePenalty = Optional.ofNullable(presencePenalty); + return this; + } + + + /** + * Penalizes tokens that have already appeared in the generated + * text. A positive value encourages the model to generate more diverse and + * less repetitive text. Valid values can range from [-2.0, 2.0]. + */ + public GenerationConfig withPresencePenalty(Optional presencePenalty) { + Utils.checkNotNull(presencePenalty, "presencePenalty"); + this.presencePenalty = presencePenalty; + return this; + } + + /** + * Penalizes tokens based on their frequency in the generated text. + * A positive value helps to reduce the repetition of words and phrases. + * Valid values can range from [-2.0, 2.0]. + */ + public GenerationConfig withFrequencyPenalty(float frequencyPenalty) { + Utils.checkNotNull(frequencyPenalty, "frequencyPenalty"); + this.frequencyPenalty = Optional.ofNullable(frequencyPenalty); + return this; + } + + + /** + * Penalizes tokens based on their frequency in the generated text. + * A positive value helps to reduce the repetition of words and phrases. + * Valid values can range from [-2.0, 2.0]. + */ + public GenerationConfig withFrequencyPenalty(Optional frequencyPenalty) { + Utils.checkNotNull(frequencyPenalty, "frequencyPenalty"); + this.frequencyPenalty = frequencyPenalty; + return this; + } + + /** + * The tool choice configuration. + */ + public GenerationConfig withToolChoice(ToolChoice toolChoice) { + Utils.checkNotNull(toolChoice, "toolChoice"); + this.toolChoice = Optional.ofNullable(toolChoice); + return this; + } + + + /** + * The tool choice configuration. + */ + public GenerationConfig withToolChoice(Optional toolChoice) { + Utils.checkNotNull(toolChoice, "toolChoice"); + this.toolChoice = toolChoice; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GenerationConfig other = (GenerationConfig) o; + return + Utils.enhancedDeepEquals(this.temperature, other.temperature) && + Utils.enhancedDeepEquals(this.topP, other.topP) && + Utils.enhancedDeepEquals(this.seed, other.seed) && + Utils.enhancedDeepEquals(this.stopSequences, other.stopSequences) && + Utils.enhancedDeepEquals(this.thinkingLevel, other.thinkingLevel) && + Utils.enhancedDeepEquals(this.thinkingSummaries, other.thinkingSummaries) && + Utils.enhancedDeepEquals(this.maxOutputTokens, other.maxOutputTokens) && + Utils.enhancedDeepEquals(this.speechConfig, other.speechConfig) && + Utils.enhancedDeepEquals(this.imageConfig, other.imageConfig) && + Utils.enhancedDeepEquals(this.videoConfig, other.videoConfig) && + Utils.enhancedDeepEquals(this.presencePenalty, other.presencePenalty) && + Utils.enhancedDeepEquals(this.frequencyPenalty, other.frequencyPenalty) && + Utils.enhancedDeepEquals(this.toolChoice, other.toolChoice); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + temperature, topP, seed, + stopSequences, thinkingLevel, thinkingSummaries, + maxOutputTokens, speechConfig, imageConfig, + videoConfig, presencePenalty, frequencyPenalty, + toolChoice); + } + + @Override + public String toString() { + return Utils.toString(GenerationConfig.class, + "temperature", temperature, + "topP", topP, + "seed", seed, + "stopSequences", stopSequences, + "thinkingLevel", thinkingLevel, + "thinkingSummaries", thinkingSummaries, + "maxOutputTokens", maxOutputTokens, + "speechConfig", speechConfig, + "imageConfig", imageConfig, + "videoConfig", videoConfig, + "presencePenalty", presencePenalty, + "frequencyPenalty", frequencyPenalty, + "toolChoice", toolChoice); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional temperature = Optional.empty(); + + private Optional topP = Optional.empty(); + + private Optional seed = Optional.empty(); + + private Optional> stopSequences = Optional.empty(); + + private Optional thinkingLevel = Optional.empty(); + + private Optional thinkingSummaries = Optional.empty(); + + private Optional maxOutputTokens = Optional.empty(); + + private Optional> speechConfig = Optional.empty(); + + @Deprecated + private Optional imageConfig = Optional.empty(); + + private Optional videoConfig = Optional.empty(); + + private Optional presencePenalty = Optional.empty(); + + private Optional frequencyPenalty = Optional.empty(); + + private Optional toolChoice = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Controls the randomness of the output. + */ + public Builder temperature(float temperature) { + Utils.checkNotNull(temperature, "temperature"); + this.temperature = Optional.ofNullable(temperature); + return this; + } + + /** + * Controls the randomness of the output. + */ + public Builder temperature(Optional temperature) { + Utils.checkNotNull(temperature, "temperature"); + this.temperature = temperature; + return this; + } + + + /** + * The maximum cumulative probability of tokens to consider when sampling. + */ + public Builder topP(float topP) { + Utils.checkNotNull(topP, "topP"); + this.topP = Optional.ofNullable(topP); + return this; + } + + /** + * The maximum cumulative probability of tokens to consider when sampling. + */ + public Builder topP(Optional topP) { + Utils.checkNotNull(topP, "topP"); + this.topP = topP; + return this; + } + + + /** + * Seed used in decoding for reproducibility. + */ + public Builder seed(int seed) { + Utils.checkNotNull(seed, "seed"); + this.seed = Optional.ofNullable(seed); + return this; + } + + /** + * Seed used in decoding for reproducibility. + */ + public Builder seed(Optional seed) { + Utils.checkNotNull(seed, "seed"); + this.seed = seed; + return this; + } + + + /** + * A list of character sequences that will stop output interaction. + */ + public Builder stopSequences(List stopSequences) { + Utils.checkNotNull(stopSequences, "stopSequences"); + this.stopSequences = Optional.ofNullable(stopSequences); + return this; + } + + /** + * A list of character sequences that will stop output interaction. + */ + public Builder stopSequences(Optional> stopSequences) { + Utils.checkNotNull(stopSequences, "stopSequences"); + this.stopSequences = stopSequences; + return this; + } + + + public Builder thinkingLevel(ThinkingLevel thinkingLevel) { + Utils.checkNotNull(thinkingLevel, "thinkingLevel"); + this.thinkingLevel = Optional.ofNullable(thinkingLevel); + return this; + } + + public Builder thinkingLevel(Optional thinkingLevel) { + Utils.checkNotNull(thinkingLevel, "thinkingLevel"); + this.thinkingLevel = thinkingLevel; + return this; + } + + + public Builder thinkingSummaries(ThinkingSummaries thinkingSummaries) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + this.thinkingSummaries = Optional.ofNullable(thinkingSummaries); + return this; + } + + public Builder thinkingSummaries(Optional thinkingSummaries) { + Utils.checkNotNull(thinkingSummaries, "thinkingSummaries"); + this.thinkingSummaries = thinkingSummaries; + return this; + } + + + /** + * The maximum number of tokens to include in the response. + */ + public Builder maxOutputTokens(int maxOutputTokens) { + Utils.checkNotNull(maxOutputTokens, "maxOutputTokens"); + this.maxOutputTokens = Optional.ofNullable(maxOutputTokens); + return this; + } + + /** + * The maximum number of tokens to include in the response. + */ + public Builder maxOutputTokens(Optional maxOutputTokens) { + Utils.checkNotNull(maxOutputTokens, "maxOutputTokens"); + this.maxOutputTokens = maxOutputTokens; + return this; + } + + + /** + * Configuration for speech interaction. + */ + public Builder speechConfig(List speechConfig) { + Utils.checkNotNull(speechConfig, "speechConfig"); + this.speechConfig = Optional.ofNullable(speechConfig); + return this; + } + + /** + * Configuration for speech interaction. + */ + public Builder speechConfig(Optional> speechConfig) { + Utils.checkNotNull(speechConfig, "speechConfig"); + this.speechConfig = speechConfig; + return this; + } + + + /** + * The configuration for image interaction. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder imageConfig(ImageConfig imageConfig) { + Utils.checkNotNull(imageConfig, "imageConfig"); + this.imageConfig = Optional.ofNullable(imageConfig); + return this; + } + + /** + * The configuration for image interaction. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder imageConfig(Optional imageConfig) { + Utils.checkNotNull(imageConfig, "imageConfig"); + this.imageConfig = imageConfig; + return this; + } + + + /** + * Configuration options for video generation. + */ + public Builder videoConfig(VideoConfig videoConfig) { + Utils.checkNotNull(videoConfig, "videoConfig"); + this.videoConfig = Optional.ofNullable(videoConfig); + return this; + } + + /** + * Configuration options for video generation. + */ + public Builder videoConfig(Optional videoConfig) { + Utils.checkNotNull(videoConfig, "videoConfig"); + this.videoConfig = videoConfig; + return this; + } + + + /** + * Penalizes tokens that have already appeared in the generated + * text. A positive value encourages the model to generate more diverse and + * less repetitive text. Valid values can range from [-2.0, 2.0]. + */ + public Builder presencePenalty(float presencePenalty) { + Utils.checkNotNull(presencePenalty, "presencePenalty"); + this.presencePenalty = Optional.ofNullable(presencePenalty); + return this; + } + + /** + * Penalizes tokens that have already appeared in the generated + * text. A positive value encourages the model to generate more diverse and + * less repetitive text. Valid values can range from [-2.0, 2.0]. + */ + public Builder presencePenalty(Optional presencePenalty) { + Utils.checkNotNull(presencePenalty, "presencePenalty"); + this.presencePenalty = presencePenalty; + return this; + } + + + /** + * Penalizes tokens based on their frequency in the generated text. + * A positive value helps to reduce the repetition of words and phrases. + * Valid values can range from [-2.0, 2.0]. + */ + public Builder frequencyPenalty(float frequencyPenalty) { + Utils.checkNotNull(frequencyPenalty, "frequencyPenalty"); + this.frequencyPenalty = Optional.ofNullable(frequencyPenalty); + return this; + } + + /** + * Penalizes tokens based on their frequency in the generated text. + * A positive value helps to reduce the repetition of words and phrases. + * Valid values can range from [-2.0, 2.0]. + */ + public Builder frequencyPenalty(Optional frequencyPenalty) { + Utils.checkNotNull(frequencyPenalty, "frequencyPenalty"); + this.frequencyPenalty = frequencyPenalty; + return this; + } + + + /** + * The tool choice configuration. + */ + public Builder toolChoice(ToolChoice toolChoice) { + Utils.checkNotNull(toolChoice, "toolChoice"); + this.toolChoice = Optional.ofNullable(toolChoice); + return this; + } + + /** + * The tool choice configuration. + */ + public Builder toolChoice(Optional toolChoice) { + Utils.checkNotNull(toolChoice, "toolChoice"); + this.toolChoice = toolChoice; + return this; + } + + public GenerationConfig build() { + + return new GenerationConfig( + temperature, topP, seed, + stopSequences, thinkingLevel, thinkingSummaries, + maxOutputTokens, speechConfig, imageConfig, + videoConfig, presencePenalty, frequencyPenalty, + toolChoice); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleMaps.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMaps.java new file mode 100644 index 00000000000..e050ff97817 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMaps.java @@ -0,0 +1,298 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Double; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * GoogleMaps + * + *

A tool that can be used by the model to call Google Maps. + */ +@SuppressWarnings("all") +public class GoogleMaps { + + @JsonProperty("type") + private String type; + + /** + * Whether to return a widget context token in the tool call result of the + * response. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("enable_widget") + private Optional enableWidget; + + /** + * The latitude of the user's location. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("latitude") + private Optional latitude; + + /** + * The longitude of the user's location. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("longitude") + private Optional longitude; + + @JsonCreator + public GoogleMaps( + @JsonProperty("enable_widget") Optional enableWidget, + @JsonProperty("latitude") Optional latitude, + @JsonProperty("longitude") Optional longitude) { + Utils.checkNotNull(enableWidget, "enableWidget"); + Utils.checkNotNull(latitude, "latitude"); + Utils.checkNotNull(longitude, "longitude"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.enableWidget = enableWidget; + this.latitude = latitude; + this.longitude = longitude; + } + + public GoogleMaps() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Whether to return a widget context token in the tool call result of the + * response. + */ + @JsonIgnore + public Optional enableWidget() { + return enableWidget; + } + + /** + * The latitude of the user's location. + */ + @JsonIgnore + public Optional latitude() { + return latitude; + } + + /** + * The longitude of the user's location. + */ + @JsonIgnore + public Optional longitude() { + return longitude; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Whether to return a widget context token in the tool call result of the + * response. + */ + public GoogleMaps withEnableWidget(boolean enableWidget) { + Utils.checkNotNull(enableWidget, "enableWidget"); + this.enableWidget = Optional.ofNullable(enableWidget); + return this; + } + + + /** + * Whether to return a widget context token in the tool call result of the + * response. + */ + public GoogleMaps withEnableWidget(Optional enableWidget) { + Utils.checkNotNull(enableWidget, "enableWidget"); + this.enableWidget = enableWidget; + return this; + } + + /** + * The latitude of the user's location. + */ + public GoogleMaps withLatitude(double latitude) { + Utils.checkNotNull(latitude, "latitude"); + this.latitude = Optional.ofNullable(latitude); + return this; + } + + + /** + * The latitude of the user's location. + */ + public GoogleMaps withLatitude(Optional latitude) { + Utils.checkNotNull(latitude, "latitude"); + this.latitude = latitude; + return this; + } + + /** + * The longitude of the user's location. + */ + public GoogleMaps withLongitude(double longitude) { + Utils.checkNotNull(longitude, "longitude"); + this.longitude = Optional.ofNullable(longitude); + return this; + } + + + /** + * The longitude of the user's location. + */ + public GoogleMaps withLongitude(Optional longitude) { + Utils.checkNotNull(longitude, "longitude"); + this.longitude = longitude; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleMaps other = (GoogleMaps) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.enableWidget, other.enableWidget) && + Utils.enhancedDeepEquals(this.latitude, other.latitude) && + Utils.enhancedDeepEquals(this.longitude, other.longitude); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, enableWidget, latitude, + longitude); + } + + @Override + public String toString() { + return Utils.toString(GoogleMaps.class, + "type", type, + "enableWidget", enableWidget, + "latitude", latitude, + "longitude", longitude); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional enableWidget = Optional.empty(); + + private Optional latitude = Optional.empty(); + + private Optional longitude = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Whether to return a widget context token in the tool call result of the + * response. + */ + public Builder enableWidget(boolean enableWidget) { + Utils.checkNotNull(enableWidget, "enableWidget"); + this.enableWidget = Optional.ofNullable(enableWidget); + return this; + } + + /** + * Whether to return a widget context token in the tool call result of the + * response. + */ + public Builder enableWidget(Optional enableWidget) { + Utils.checkNotNull(enableWidget, "enableWidget"); + this.enableWidget = enableWidget; + return this; + } + + + /** + * The latitude of the user's location. + */ + public Builder latitude(double latitude) { + Utils.checkNotNull(latitude, "latitude"); + this.latitude = Optional.ofNullable(latitude); + return this; + } + + /** + * The latitude of the user's location. + */ + public Builder latitude(Optional latitude) { + Utils.checkNotNull(latitude, "latitude"); + this.latitude = latitude; + return this; + } + + + /** + * The longitude of the user's location. + */ + public Builder longitude(double longitude) { + Utils.checkNotNull(longitude, "longitude"); + this.longitude = Optional.ofNullable(longitude); + return this; + } + + /** + * The longitude of the user's location. + */ + public Builder longitude(Optional longitude) { + Utils.checkNotNull(longitude, "longitude"); + this.longitude = longitude; + return this; + } + + public GoogleMaps build() { + + return new GoogleMaps( + enableWidget, latitude, longitude); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_maps\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallArguments.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallArguments.java new file mode 100644 index 00000000000..a1730636df2 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallArguments.java @@ -0,0 +1,152 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * GoogleMapsCallArguments + * + *

The arguments to pass to the Google Maps tool. + */ +@SuppressWarnings("all") +public class GoogleMapsCallArguments { + /** + * The queries to be executed. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("queries") + private Optional> queries; + + @JsonCreator + public GoogleMapsCallArguments( + @JsonProperty("queries") Optional> queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = queries; + } + + public GoogleMapsCallArguments() { + this(Optional.empty()); + } + + /** + * The queries to be executed. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> queries() { + return (Optional>) queries; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The queries to be executed. + */ + public GoogleMapsCallArguments withQueries(List queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = Optional.ofNullable(queries); + return this; + } + + + /** + * The queries to be executed. + */ + public GoogleMapsCallArguments withQueries(Optional> queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = queries; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleMapsCallArguments other = (GoogleMapsCallArguments) o; + return + Utils.enhancedDeepEquals(this.queries, other.queries); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + queries); + } + + @Override + public String toString() { + return Utils.toString(GoogleMapsCallArguments.class, + "queries", queries); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> queries = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The queries to be executed. + */ + public Builder queries(List queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = Optional.ofNullable(queries); + return this; + } + + /** + * The queries to be executed. + */ + public Builder queries(Optional> queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = queries; + return this; + } + + public GoogleMapsCallArguments build() { + + return new GoogleMapsCallArguments( + queries); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallDelta.java new file mode 100644 index 00000000000..0634e0f68e8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallDelta.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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GoogleMapsCallDelta { + + @JsonProperty("type") + private String type; + + /** + * The arguments to pass to the Google Maps tool. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("arguments") + private Optional arguments; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public GoogleMapsCallDelta( + @JsonProperty("arguments") Optional arguments, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.arguments = arguments; + this.signature = signature; + } + + public GoogleMapsCallDelta() { + this(Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The arguments to pass to the Google Maps tool. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional arguments() { + return (Optional) arguments; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The arguments to pass to the Google Maps tool. + */ + public GoogleMapsCallDelta withArguments(GoogleMapsCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = Optional.ofNullable(arguments); + return this; + } + + + /** + * The arguments to pass to the Google Maps tool. + */ + public GoogleMapsCallDelta withArguments(Optional arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * A signature hash for backend validation. + */ + public GoogleMapsCallDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public GoogleMapsCallDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleMapsCallDelta other = (GoogleMapsCallDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, arguments, signature); + } + + @Override + public String toString() { + return Utils.toString(GoogleMapsCallDelta.class, + "type", type, + "arguments", arguments, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional arguments = Optional.empty(); + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The arguments to pass to the Google Maps tool. + */ + public Builder arguments(GoogleMapsCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = Optional.ofNullable(arguments); + return this; + } + + /** + * The arguments to pass to the Google Maps tool. + */ + public Builder arguments(Optional arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public GoogleMapsCallDelta build() { + + return new GoogleMapsCallDelta( + arguments, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_maps_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallStep.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallStep.java new file mode 100644 index 00000000000..7d3e5245bc8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsCallStep.java @@ -0,0 +1,273 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * GoogleMapsCallStep + * + *

Google Maps call step. + */ +@SuppressWarnings("all") +public class GoogleMapsCallStep { + + @JsonProperty("type") + private String type; + + /** + * The arguments to pass to the Google Maps tool. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("arguments") + private Optional arguments; + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonProperty("id") + private String id; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public GoogleMapsCallStep( + @JsonProperty("arguments") Optional arguments, + @JsonProperty("id") String id, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.arguments = arguments; + this.id = id; + this.signature = signature; + } + + public GoogleMapsCallStep( + String id) { + this(Optional.empty(), id, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The arguments to pass to the Google Maps tool. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional arguments() { + return (Optional) arguments; + } + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The arguments to pass to the Google Maps tool. + */ + public GoogleMapsCallStep withArguments(GoogleMapsCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = Optional.ofNullable(arguments); + return this; + } + + + /** + * The arguments to pass to the Google Maps tool. + */ + public GoogleMapsCallStep withArguments(Optional arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * Required. A unique ID for this specific tool call. + */ + public GoogleMapsCallStep withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * A signature hash for backend validation. + */ + public GoogleMapsCallStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public GoogleMapsCallStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleMapsCallStep other = (GoogleMapsCallStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, arguments, id, + signature); + } + + @Override + public String toString() { + return Utils.toString(GoogleMapsCallStep.class, + "type", type, + "arguments", arguments, + "id", id, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional arguments = Optional.empty(); + + private String id; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The arguments to pass to the Google Maps tool. + */ + public Builder arguments(GoogleMapsCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = Optional.ofNullable(arguments); + return this; + } + + /** + * The arguments to pass to the Google Maps tool. + */ + public Builder arguments(Optional arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public GoogleMapsCallStep build() { + + return new GoogleMapsCallStep( + arguments, id, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_maps_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResult.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResult.java new file mode 100644 index 00000000000..8205c61d78c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResult.java @@ -0,0 +1,178 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * GoogleMapsResult + * + *

The result of the Google Maps. + */ +@SuppressWarnings("all") +public class GoogleMapsResult { + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("places") + private Optional> places; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("widget_context_token") + private Optional widgetContextToken; + + @JsonCreator + public GoogleMapsResult( + @JsonProperty("places") Optional> places, + @JsonProperty("widget_context_token") Optional widgetContextToken) { + Utils.checkNotNull(places, "places"); + Utils.checkNotNull(widgetContextToken, "widgetContextToken"); + this.places = places; + this.widgetContextToken = widgetContextToken; + } + + public GoogleMapsResult() { + this(Optional.empty(), Optional.empty()); + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> places() { + return (Optional>) places; + } + + @JsonIgnore + public Optional widgetContextToken() { + return widgetContextToken; + } + + public static Builder builder() { + return new Builder(); + } + + + public GoogleMapsResult withPlaces(List places) { + Utils.checkNotNull(places, "places"); + this.places = Optional.ofNullable(places); + return this; + } + + + public GoogleMapsResult withPlaces(Optional> places) { + Utils.checkNotNull(places, "places"); + this.places = places; + return this; + } + + public GoogleMapsResult withWidgetContextToken(String widgetContextToken) { + Utils.checkNotNull(widgetContextToken, "widgetContextToken"); + this.widgetContextToken = Optional.ofNullable(widgetContextToken); + return this; + } + + + public GoogleMapsResult withWidgetContextToken(Optional widgetContextToken) { + Utils.checkNotNull(widgetContextToken, "widgetContextToken"); + this.widgetContextToken = widgetContextToken; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleMapsResult other = (GoogleMapsResult) o; + return + Utils.enhancedDeepEquals(this.places, other.places) && + Utils.enhancedDeepEquals(this.widgetContextToken, other.widgetContextToken); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + places, widgetContextToken); + } + + @Override + public String toString() { + return Utils.toString(GoogleMapsResult.class, + "places", places, + "widgetContextToken", widgetContextToken); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> places = Optional.empty(); + + private Optional widgetContextToken = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder places(List places) { + Utils.checkNotNull(places, "places"); + this.places = Optional.ofNullable(places); + return this; + } + + public Builder places(Optional> places) { + Utils.checkNotNull(places, "places"); + this.places = places; + return this; + } + + + public Builder widgetContextToken(String widgetContextToken) { + Utils.checkNotNull(widgetContextToken, "widgetContextToken"); + this.widgetContextToken = Optional.ofNullable(widgetContextToken); + return this; + } + + public Builder widgetContextToken(Optional widgetContextToken) { + Utils.checkNotNull(widgetContextToken, "widgetContextToken"); + this.widgetContextToken = widgetContextToken; + return this; + } + + public GoogleMapsResult build() { + + return new GoogleMapsResult( + places, widgetContextToken); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultDelta.java new file mode 100644 index 00000000000..01955f2ed2e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultDelta.java @@ -0,0 +1,228 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GoogleMapsResultDelta { + + @JsonProperty("type") + private String type; + + /** + * The results of the Google Maps. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("result") + private Optional> result; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public GoogleMapsResultDelta( + @JsonProperty("result") Optional> result, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.signature = signature; + } + + public GoogleMapsResultDelta() { + this(Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The results of the Google Maps. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> result() { + return (Optional>) result; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The results of the Google Maps. + */ + public GoogleMapsResultDelta withResult(List result) { + Utils.checkNotNull(result, "result"); + this.result = Optional.ofNullable(result); + return this; + } + + + /** + * The results of the Google Maps. + */ + public GoogleMapsResultDelta withResult(Optional> result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + /** + * A signature hash for backend validation. + */ + public GoogleMapsResultDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public GoogleMapsResultDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleMapsResultDelta other = (GoogleMapsResultDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, signature); + } + + @Override + public String toString() { + return Utils.toString(GoogleMapsResultDelta.class, + "type", type, + "result", result, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> result = Optional.empty(); + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The results of the Google Maps. + */ + public Builder result(List result) { + Utils.checkNotNull(result, "result"); + this.result = Optional.ofNullable(result); + return this; + } + + /** + * The results of the Google Maps. + */ + public Builder result(Optional> result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public GoogleMapsResultDelta build() { + + return new GoogleMapsResultDelta( + result, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_maps_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultPlaces.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultPlaces.java new file mode 100644 index 00000000000..fbb0c35c30d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultPlaces.java @@ -0,0 +1,263 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GoogleMapsResultPlaces { + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("place_id") + private Optional placeId; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("url") + private Optional url; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("review_snippets") + private Optional> reviewSnippets; + + @JsonCreator + public GoogleMapsResultPlaces( + @JsonProperty("place_id") Optional placeId, + @JsonProperty("name") Optional name, + @JsonProperty("url") Optional url, + @JsonProperty("review_snippets") Optional> reviewSnippets) { + Utils.checkNotNull(placeId, "placeId"); + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(url, "url"); + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.placeId = placeId; + this.name = name; + this.url = url; + this.reviewSnippets = reviewSnippets; + } + + public GoogleMapsResultPlaces() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public Optional placeId() { + return placeId; + } + + @JsonIgnore + public Optional name() { + return name; + } + + @JsonIgnore + public Optional url() { + return url; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> reviewSnippets() { + return (Optional>) reviewSnippets; + } + + public static Builder builder() { + return new Builder(); + } + + + public GoogleMapsResultPlaces withPlaceId(String placeId) { + Utils.checkNotNull(placeId, "placeId"); + this.placeId = Optional.ofNullable(placeId); + return this; + } + + + public GoogleMapsResultPlaces withPlaceId(Optional placeId) { + Utils.checkNotNull(placeId, "placeId"); + this.placeId = placeId; + return this; + } + + public GoogleMapsResultPlaces withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + public GoogleMapsResultPlaces withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + public GoogleMapsResultPlaces withUrl(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + + public GoogleMapsResultPlaces withUrl(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + public GoogleMapsResultPlaces withReviewSnippets(List reviewSnippets) { + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.reviewSnippets = Optional.ofNullable(reviewSnippets); + return this; + } + + + public GoogleMapsResultPlaces withReviewSnippets(Optional> reviewSnippets) { + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.reviewSnippets = reviewSnippets; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleMapsResultPlaces other = (GoogleMapsResultPlaces) o; + return + Utils.enhancedDeepEquals(this.placeId, other.placeId) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.url, other.url) && + Utils.enhancedDeepEquals(this.reviewSnippets, other.reviewSnippets); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + placeId, name, url, + reviewSnippets); + } + + @Override + public String toString() { + return Utils.toString(GoogleMapsResultPlaces.class, + "placeId", placeId, + "name", name, + "url", url, + "reviewSnippets", reviewSnippets); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional placeId = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional> reviewSnippets = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder placeId(String placeId) { + Utils.checkNotNull(placeId, "placeId"); + this.placeId = Optional.ofNullable(placeId); + return this; + } + + public Builder placeId(Optional placeId) { + Utils.checkNotNull(placeId, "placeId"); + this.placeId = placeId; + return this; + } + + + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + public Builder url(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + public Builder url(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + + public Builder reviewSnippets(List reviewSnippets) { + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.reviewSnippets = Optional.ofNullable(reviewSnippets); + return this; + } + + public Builder reviewSnippets(Optional> reviewSnippets) { + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.reviewSnippets = reviewSnippets; + return this; + } + + public GoogleMapsResultPlaces build() { + + return new GoogleMapsResultPlaces( + placeId, name, url, + reviewSnippets); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultStep.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultStep.java new file mode 100644 index 00000000000..d140606f7a7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleMapsResultStep.java @@ -0,0 +1,242 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + +/** + * GoogleMapsResultStep + * + *

Google Maps result step. + */ +@SuppressWarnings("all") +public class GoogleMapsResultStep { + + @JsonProperty("type") + private String type; + + + @JsonProperty("result") + private List result; + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonProperty("call_id") + private String callId; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public GoogleMapsResultStep( + @JsonProperty("result") List result, + @JsonProperty("call_id") String callId, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(callId, "callId"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.callId = callId; + this.signature = signature; + } + + public GoogleMapsResultStep( + List result, + String callId) { + this(result, callId, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public List result() { + return result; + } + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonIgnore + public String callId() { + return callId; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + public GoogleMapsResultStep withResult(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + /** + * Required. ID to match the ID from the function call block. + */ + public GoogleMapsResultStep withCallId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + /** + * A signature hash for backend validation. + */ + public GoogleMapsResultStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public GoogleMapsResultStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleMapsResultStep other = (GoogleMapsResultStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.callId, other.callId) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, callId, + signature); + } + + @Override + public String toString() { + return Utils.toString(GoogleMapsResultStep.class, + "type", type, + "result", result, + "callId", callId, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private List result; + + private String callId; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder result(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public Builder callId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public GoogleMapsResultStep build() { + + return new GoogleMapsResultStep( + result, callId, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_maps_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearch.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearch.java new file mode 100644 index 00000000000..b13971ad27a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearch.java @@ -0,0 +1,145 @@ +/* +* 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.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + +/** + * GoogleSearch + * + *

A tool that can be used by the model to search Google. + */ +@SuppressWarnings("all") +public class GoogleSearch { + + @JsonProperty("type") + private String type; + + /** + * The types of search grounding to enable. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("search_types") + private List searchTypes; + + @JsonCreator + public GoogleSearch( + @JsonProperty("search_types") @Nullable List searchTypes) { + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.searchTypes = searchTypes; + } + + public GoogleSearch() { + this(null); + } + + public String type() { + return Utils.discriminatorToString(type); + } + + /** + * The types of search grounding to enable. + */ + public Optional> searchTypes() { + return Optional.ofNullable(this.searchTypes); + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The types of search grounding to enable. + */ + public GoogleSearch withSearchTypes(@Nullable List searchTypes) { + this.searchTypes = searchTypes; + return this; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleSearch other = (GoogleSearch) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.searchTypes, other.searchTypes); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, searchTypes); + } + + @Override + public String toString() { + return Utils.toString(GoogleSearch.class, + "type", type, + "searchTypes", searchTypes); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private List searchTypes; + + private Builder() { + // force use of static builder() method + } + + /** + * The types of search grounding to enable. + */ + public Builder searchTypes(@Nullable List searchTypes) { + this.searchTypes = searchTypes; + return this; + } + + public GoogleSearch build() { + return new GoogleSearch( + searchTypes); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_search\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallArguments.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallArguments.java new file mode 100644 index 00000000000..b538c641db5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallArguments.java @@ -0,0 +1,152 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * GoogleSearchCallArguments + * + *

The arguments to pass to Google Search. + */ +@SuppressWarnings("all") +public class GoogleSearchCallArguments { + /** + * Web search queries for the following-up web search. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("queries") + private Optional> queries; + + @JsonCreator + public GoogleSearchCallArguments( + @JsonProperty("queries") Optional> queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = queries; + } + + public GoogleSearchCallArguments() { + this(Optional.empty()); + } + + /** + * Web search queries for the following-up web search. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> queries() { + return (Optional>) queries; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Web search queries for the following-up web search. + */ + public GoogleSearchCallArguments withQueries(List queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = Optional.ofNullable(queries); + return this; + } + + + /** + * Web search queries for the following-up web search. + */ + public GoogleSearchCallArguments withQueries(Optional> queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = queries; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleSearchCallArguments other = (GoogleSearchCallArguments) o; + return + Utils.enhancedDeepEquals(this.queries, other.queries); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + queries); + } + + @Override + public String toString() { + return Utils.toString(GoogleSearchCallArguments.class, + "queries", queries); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> queries = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Web search queries for the following-up web search. + */ + public Builder queries(List queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = Optional.ofNullable(queries); + return this; + } + + /** + * Web search queries for the following-up web search. + */ + public Builder queries(Optional> queries) { + Utils.checkNotNull(queries, "queries"); + this.queries = queries; + return this; + } + + public GoogleSearchCallArguments build() { + + return new GoogleSearchCallArguments( + queries); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallDelta.java new file mode 100644 index 00000000000..b78c3b89102 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallDelta.java @@ -0,0 +1,206 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GoogleSearchCallDelta { + + @JsonProperty("type") + private String type; + + /** + * The arguments to pass to Google Search. + */ + @JsonProperty("arguments") + private GoogleSearchCallArguments arguments; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public GoogleSearchCallDelta( + @JsonProperty("arguments") GoogleSearchCallArguments arguments, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.arguments = arguments; + this.signature = signature; + } + + public GoogleSearchCallDelta( + GoogleSearchCallArguments arguments) { + this(arguments, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The arguments to pass to Google Search. + */ + @JsonIgnore + public GoogleSearchCallArguments arguments() { + return arguments; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The arguments to pass to Google Search. + */ + public GoogleSearchCallDelta withArguments(GoogleSearchCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * A signature hash for backend validation. + */ + public GoogleSearchCallDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public GoogleSearchCallDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleSearchCallDelta other = (GoogleSearchCallDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, arguments, signature); + } + + @Override + public String toString() { + return Utils.toString(GoogleSearchCallDelta.class, + "type", type, + "arguments", arguments, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private GoogleSearchCallArguments arguments; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The arguments to pass to Google Search. + */ + public Builder arguments(GoogleSearchCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public GoogleSearchCallDelta build() { + + return new GoogleSearchCallDelta( + arguments, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_search_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallStep.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallStep.java new file mode 100644 index 00000000000..1e0d6e7abe1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallStep.java @@ -0,0 +1,316 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * GoogleSearchCallStep + * + *

Google Search call step. + */ +@SuppressWarnings("all") +public class GoogleSearchCallStep { + + @JsonProperty("type") + private String type; + + /** + * The arguments to pass to Google Search. + */ + @JsonProperty("arguments") + private GoogleSearchCallArguments arguments; + + /** + * The type of search grounding enabled. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("search_type") + private Optional searchType; + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonProperty("id") + private String id; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public GoogleSearchCallStep( + @JsonProperty("arguments") GoogleSearchCallArguments arguments, + @JsonProperty("search_type") Optional searchType, + @JsonProperty("id") String id, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(searchType, "searchType"); + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.arguments = arguments; + this.searchType = searchType; + this.id = id; + this.signature = signature; + } + + public GoogleSearchCallStep( + GoogleSearchCallArguments arguments, + String id) { + this(arguments, Optional.empty(), id, + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The arguments to pass to Google Search. + */ + @JsonIgnore + public GoogleSearchCallArguments arguments() { + return arguments; + } + + /** + * The type of search grounding enabled. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional searchType() { + return (Optional) searchType; + } + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The arguments to pass to Google Search. + */ + public GoogleSearchCallStep withArguments(GoogleSearchCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * The type of search grounding enabled. + */ + public GoogleSearchCallStep withSearchType(GoogleSearchCallStepSearchType searchType) { + Utils.checkNotNull(searchType, "searchType"); + this.searchType = Optional.ofNullable(searchType); + return this; + } + + + /** + * The type of search grounding enabled. + */ + public GoogleSearchCallStep withSearchType(Optional searchType) { + Utils.checkNotNull(searchType, "searchType"); + this.searchType = searchType; + return this; + } + + /** + * Required. A unique ID for this specific tool call. + */ + public GoogleSearchCallStep withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * A signature hash for backend validation. + */ + public GoogleSearchCallStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public GoogleSearchCallStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleSearchCallStep other = (GoogleSearchCallStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.searchType, other.searchType) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, arguments, searchType, + id, signature); + } + + @Override + public String toString() { + return Utils.toString(GoogleSearchCallStep.class, + "type", type, + "arguments", arguments, + "searchType", searchType, + "id", id, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private GoogleSearchCallArguments arguments; + + private Optional searchType = Optional.empty(); + + private String id; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The arguments to pass to Google Search. + */ + public Builder arguments(GoogleSearchCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * The type of search grounding enabled. + */ + public Builder searchType(GoogleSearchCallStepSearchType searchType) { + Utils.checkNotNull(searchType, "searchType"); + this.searchType = Optional.ofNullable(searchType); + return this; + } + + /** + * The type of search grounding enabled. + */ + public Builder searchType(Optional searchType) { + Utils.checkNotNull(searchType, "searchType"); + this.searchType = searchType; + return this; + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public GoogleSearchCallStep build() { + + return new GoogleSearchCallStep( + arguments, searchType, id, + signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_search_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallStepSearchType.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallStepSearchType.java new file mode 100644 index 00000000000..4cf2323830e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchCallStepSearchType.java @@ -0,0 +1,58 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * GoogleSearchCallStepSearchType + * + *

The type of search grounding enabled. + */ +@SuppressWarnings("all") +public enum GoogleSearchCallStepSearchType { + WEB_SEARCH("web_search"), + IMAGE_SEARCH("image_search"), + ENTERPRISE_WEB_SEARCH("enterprise_web_search"); + + @JsonValue + private final String value; + + GoogleSearchCallStepSearchType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (GoogleSearchCallStepSearchType o: GoogleSearchCallStepSearchType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResult.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResult.java new file mode 100644 index 00000000000..a300d5c9cd4 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResult.java @@ -0,0 +1,149 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * GoogleSearchResult + * + *

The result of the Google Search. + */ +@SuppressWarnings("all") +public class GoogleSearchResult { + /** + * Web content snippet that can be embedded in a web page or an app webview. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("search_suggestions") + private Optional searchSuggestions; + + @JsonCreator + public GoogleSearchResult( + @JsonProperty("search_suggestions") Optional searchSuggestions) { + Utils.checkNotNull(searchSuggestions, "searchSuggestions"); + this.searchSuggestions = searchSuggestions; + } + + public GoogleSearchResult() { + this(Optional.empty()); + } + + /** + * Web content snippet that can be embedded in a web page or an app webview. + */ + @JsonIgnore + public Optional searchSuggestions() { + return searchSuggestions; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Web content snippet that can be embedded in a web page or an app webview. + */ + public GoogleSearchResult withSearchSuggestions(String searchSuggestions) { + Utils.checkNotNull(searchSuggestions, "searchSuggestions"); + this.searchSuggestions = Optional.ofNullable(searchSuggestions); + return this; + } + + + /** + * Web content snippet that can be embedded in a web page or an app webview. + */ + public GoogleSearchResult withSearchSuggestions(Optional searchSuggestions) { + Utils.checkNotNull(searchSuggestions, "searchSuggestions"); + this.searchSuggestions = searchSuggestions; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleSearchResult other = (GoogleSearchResult) o; + return + Utils.enhancedDeepEquals(this.searchSuggestions, other.searchSuggestions); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + searchSuggestions); + } + + @Override + public String toString() { + return Utils.toString(GoogleSearchResult.class, + "searchSuggestions", searchSuggestions); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional searchSuggestions = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Web content snippet that can be embedded in a web page or an app webview. + */ + public Builder searchSuggestions(String searchSuggestions) { + Utils.checkNotNull(searchSuggestions, "searchSuggestions"); + this.searchSuggestions = Optional.ofNullable(searchSuggestions); + return this; + } + + /** + * Web content snippet that can be embedded in a web page or an app webview. + */ + public Builder searchSuggestions(Optional searchSuggestions) { + Utils.checkNotNull(searchSuggestions, "searchSuggestions"); + this.searchSuggestions = searchSuggestions; + return this; + } + + public GoogleSearchResult build() { + + return new GoogleSearchResult( + searchSuggestions); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResultDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResultDelta.java new file mode 100644 index 00000000000..8bbf209c4b0 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResultDelta.java @@ -0,0 +1,241 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GoogleSearchResultDelta { + + @JsonProperty("type") + private String type; + + + @JsonProperty("result") + private List result; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("is_error") + private Optional isError; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public GoogleSearchResultDelta( + @JsonProperty("result") List result, + @JsonProperty("is_error") Optional isError, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(isError, "isError"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.isError = isError; + this.signature = signature; + } + + public GoogleSearchResultDelta( + List result) { + this(result, Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public List result() { + return result; + } + + @JsonIgnore + public Optional isError() { + return isError; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + public GoogleSearchResultDelta withResult(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + public GoogleSearchResultDelta withIsError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + + public GoogleSearchResultDelta withIsError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + /** + * A signature hash for backend validation. + */ + public GoogleSearchResultDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public GoogleSearchResultDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleSearchResultDelta other = (GoogleSearchResultDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.isError, other.isError) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, isError, + signature); + } + + @Override + public String toString() { + return Utils.toString(GoogleSearchResultDelta.class, + "type", type, + "result", result, + "isError", isError, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private List result; + + private Optional isError = Optional.empty(); + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder result(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + public Builder isError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + public Builder isError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public GoogleSearchResultDelta build() { + + return new GoogleSearchResultDelta( + result, isError, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_search_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResultStep.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResultStep.java new file mode 100644 index 00000000000..0ff377f26f9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchResultStep.java @@ -0,0 +1,316 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + +/** + * GoogleSearchResultStep + * + *

Google Search result step. + */ +@SuppressWarnings("all") +public class GoogleSearchResultStep { + + @JsonProperty("type") + private String type; + + /** + * Required. The results of the Google Search. + */ + @JsonProperty("result") + private List result; + + /** + * Whether the Google Search resulted in an error. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("is_error") + private Optional isError; + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonProperty("call_id") + private String callId; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public GoogleSearchResultStep( + @JsonProperty("result") List result, + @JsonProperty("is_error") Optional isError, + @JsonProperty("call_id") String callId, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(isError, "isError"); + Utils.checkNotNull(callId, "callId"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.isError = isError; + this.callId = callId; + this.signature = signature; + } + + public GoogleSearchResultStep( + List result, + String callId) { + this(result, Optional.empty(), callId, + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. The results of the Google Search. + */ + @JsonIgnore + public List result() { + return result; + } + + /** + * Whether the Google Search resulted in an error. + */ + @JsonIgnore + public Optional isError() { + return isError; + } + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonIgnore + public String callId() { + return callId; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. The results of the Google Search. + */ + public GoogleSearchResultStep withResult(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + /** + * Whether the Google Search resulted in an error. + */ + public GoogleSearchResultStep withIsError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + + /** + * Whether the Google Search resulted in an error. + */ + public GoogleSearchResultStep withIsError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + /** + * Required. ID to match the ID from the function call block. + */ + public GoogleSearchResultStep withCallId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + /** + * A signature hash for backend validation. + */ + public GoogleSearchResultStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public GoogleSearchResultStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleSearchResultStep other = (GoogleSearchResultStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.isError, other.isError) && + Utils.enhancedDeepEquals(this.callId, other.callId) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, isError, + callId, signature); + } + + @Override + public String toString() { + return Utils.toString(GoogleSearchResultStep.class, + "type", type, + "result", result, + "isError", isError, + "callId", callId, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private List result; + + private Optional isError = Optional.empty(); + + private String callId; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. The results of the Google Search. + */ + public Builder result(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + /** + * Whether the Google Search resulted in an error. + */ + public Builder isError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + /** + * Whether the Google Search resulted in an error. + */ + public Builder isError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public Builder callId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public GoogleSearchResultStep build() { + + return new GoogleSearchResultStep( + result, isError, callId, + signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"google_search_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchSearchType.java b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchSearchType.java new file mode 100644 index 00000000000..61232fbeb6b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GoogleSearchSearchType.java @@ -0,0 +1,53 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum GoogleSearchSearchType { + WEB_SEARCH("web_search"), + IMAGE_SEARCH("image_search"), + ENTERPRISE_WEB_SEARCH("enterprise_web_search"); + + @JsonValue + private final String value; + + GoogleSearchSearchType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (GoogleSearchSearchType o: GoogleSearchSearchType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GroundingToolCount.java b/src/main/java/com/google/genai/gaos/models/interactions/GroundingToolCount.java new file mode 100644 index 00000000000..125eb35830f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GroundingToolCount.java @@ -0,0 +1,212 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * GroundingToolCount + * + *

The number of grounding tool counts. + */ +@SuppressWarnings("all") +public class GroundingToolCount { + /** + * The grounding tool type associated with the count. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("type") + private Optional type; + + /** + * The number of grounding tool counts. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("count") + private Optional count; + + @JsonCreator + public GroundingToolCount( + @JsonProperty("type") Optional type, + @JsonProperty("count") Optional count) { + Utils.checkNotNull(type, "type"); + Utils.checkNotNull(count, "count"); + this.type = type; + this.count = count; + } + + public GroundingToolCount() { + this(Optional.empty(), Optional.empty()); + } + + /** + * The grounding tool type associated with the count. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional type() { + return (Optional) type; + } + + /** + * The number of grounding tool counts. + */ + @JsonIgnore + public Optional count() { + return count; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The grounding tool type associated with the count. + */ + public GroundingToolCount withType(GroundingToolCountType type) { + Utils.checkNotNull(type, "type"); + this.type = Optional.ofNullable(type); + return this; + } + + + /** + * The grounding tool type associated with the count. + */ + public GroundingToolCount withType(Optional type) { + Utils.checkNotNull(type, "type"); + this.type = type; + return this; + } + + /** + * The number of grounding tool counts. + */ + public GroundingToolCount withCount(int count) { + Utils.checkNotNull(count, "count"); + this.count = Optional.ofNullable(count); + return this; + } + + + /** + * The number of grounding tool counts. + */ + public GroundingToolCount withCount(Optional count) { + Utils.checkNotNull(count, "count"); + this.count = count; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GroundingToolCount other = (GroundingToolCount) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.count, other.count); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, count); + } + + @Override + public String toString() { + return Utils.toString(GroundingToolCount.class, + "type", type, + "count", count); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional type = Optional.empty(); + + private Optional count = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The grounding tool type associated with the count. + */ + public Builder type(GroundingToolCountType type) { + Utils.checkNotNull(type, "type"); + this.type = Optional.ofNullable(type); + return this; + } + + /** + * The grounding tool type associated with the count. + */ + public Builder type(Optional type) { + Utils.checkNotNull(type, "type"); + this.type = type; + return this; + } + + + /** + * The number of grounding tool counts. + */ + public Builder count(int count) { + Utils.checkNotNull(count, "count"); + this.count = Optional.ofNullable(count); + return this; + } + + /** + * The number of grounding tool counts. + */ + public Builder count(Optional count) { + Utils.checkNotNull(count, "count"); + this.count = count; + return this; + } + + public GroundingToolCount build() { + + return new GroundingToolCount( + type, count); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GroundingToolCountType.java b/src/main/java/com/google/genai/gaos/models/interactions/GroundingToolCountType.java new file mode 100644 index 00000000000..0a9b49bfc07 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/GroundingToolCountType.java @@ -0,0 +1,58 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * GroundingToolCountType + * + *

The grounding tool type associated with the count. + */ +@SuppressWarnings("all") +public enum GroundingToolCountType { + GOOGLE_SEARCH("google_search"), + GOOGLE_MAPS("google_maps"), + RETRIEVAL("retrieval"); + + @JsonValue + private final String value; + + GroundingToolCountType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (GroundingToolCountType o: GroundingToolCountType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/HybridSearch.java b/src/main/java/com/google/genai/gaos/models/interactions/HybridSearch.java new file mode 100644 index 00000000000..5924d66ab74 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/HybridSearch.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.JsonIgnore; +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 java.lang.Float; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * HybridSearch + * + *

Config for Hybrid Search. + */ +@SuppressWarnings("all") +public class HybridSearch { + /** + * Optional. Alpha value controls the weight between dense and sparse vector search + * results. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("alpha") + private Optional alpha; + + @JsonCreator + public HybridSearch( + @JsonProperty("alpha") Optional alpha) { + Utils.checkNotNull(alpha, "alpha"); + this.alpha = alpha; + } + + public HybridSearch() { + this(Optional.empty()); + } + + /** + * Optional. Alpha value controls the weight between dense and sparse vector search + * results. + */ + @JsonIgnore + public Optional alpha() { + return alpha; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. Alpha value controls the weight between dense and sparse vector search + * results. + */ + public HybridSearch withAlpha(float alpha) { + Utils.checkNotNull(alpha, "alpha"); + this.alpha = Optional.ofNullable(alpha); + return this; + } + + + /** + * Optional. Alpha value controls the weight between dense and sparse vector search + * results. + */ + public HybridSearch withAlpha(Optional alpha) { + Utils.checkNotNull(alpha, "alpha"); + this.alpha = alpha; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HybridSearch other = (HybridSearch) o; + return + Utils.enhancedDeepEquals(this.alpha, other.alpha); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + alpha); + } + + @Override + public String toString() { + return Utils.toString(HybridSearch.class, + "alpha", alpha); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional alpha = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. Alpha value controls the weight between dense and sparse vector search + * results. + */ + public Builder alpha(float alpha) { + Utils.checkNotNull(alpha, "alpha"); + this.alpha = Optional.ofNullable(alpha); + return this; + } + + /** + * Optional. Alpha value controls the weight between dense and sparse vector search + * results. + */ + public Builder alpha(Optional alpha) { + Utils.checkNotNull(alpha, "alpha"); + this.alpha = alpha; + return this; + } + + public HybridSearch build() { + + return new HybridSearch( + alpha); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageConfig.java new file mode 100644 index 00000000000..7136e75ff61 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageConfig.java @@ -0,0 +1,182 @@ +/* +* 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.JsonIgnore; +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 java.lang.Deprecated; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * ImageConfig + * + *

The configuration for image interaction. + * + * @deprecated class: This will be removed in a future release, please migrate away from it as soon as possible. + */ +@Deprecated +@SuppressWarnings("all") +public class ImageConfig { + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("aspect_ratio") + private Optional aspectRatio; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("image_size") + private Optional imageSize; + + @JsonCreator + public ImageConfig( + @JsonProperty("aspect_ratio") Optional aspectRatio, + @JsonProperty("image_size") Optional imageSize) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + Utils.checkNotNull(imageSize, "imageSize"); + this.aspectRatio = aspectRatio; + this.imageSize = imageSize; + } + + public ImageConfig() { + this(Optional.empty(), Optional.empty()); + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional aspectRatio() { + return (Optional) aspectRatio; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional imageSize() { + return (Optional) imageSize; + } + + public static Builder builder() { + return new Builder(); + } + + + public ImageConfig withAspectRatio(ImageConfigAspectRatio aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = Optional.ofNullable(aspectRatio); + return this; + } + + + public ImageConfig withAspectRatio(Optional aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = aspectRatio; + return this; + } + + public ImageConfig withImageSize(ImageConfigImageSize imageSize) { + Utils.checkNotNull(imageSize, "imageSize"); + this.imageSize = Optional.ofNullable(imageSize); + return this; + } + + + public ImageConfig withImageSize(Optional imageSize) { + Utils.checkNotNull(imageSize, "imageSize"); + this.imageSize = imageSize; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ImageConfig other = (ImageConfig) o; + return + Utils.enhancedDeepEquals(this.aspectRatio, other.aspectRatio) && + Utils.enhancedDeepEquals(this.imageSize, other.imageSize); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + aspectRatio, imageSize); + } + + @Override + public String toString() { + return Utils.toString(ImageConfig.class, + "aspectRatio", aspectRatio, + "imageSize", imageSize); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional aspectRatio = Optional.empty(); + + private Optional imageSize = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder aspectRatio(ImageConfigAspectRatio aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = Optional.ofNullable(aspectRatio); + return this; + } + + public Builder aspectRatio(Optional aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = aspectRatio; + return this; + } + + + public Builder imageSize(ImageConfigImageSize imageSize) { + Utils.checkNotNull(imageSize, "imageSize"); + this.imageSize = Optional.ofNullable(imageSize); + return this; + } + + public Builder imageSize(Optional imageSize) { + Utils.checkNotNull(imageSize, "imageSize"); + this.imageSize = imageSize; + return this; + } + + public ImageConfig build() { + + return new ImageConfig( + aspectRatio, imageSize); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageConfigAspectRatio.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageConfigAspectRatio.java new file mode 100644 index 00000000000..03e77c52479 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageConfigAspectRatio.java @@ -0,0 +1,64 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum ImageConfigAspectRatio { + ELEVEN("1:1"), + TWENTY_THREE("2:3"), + THIRTY_TWO("3:2"), + THIRTY_FOUR("3:4"), + FORTY_THREE("4:3"), + FORTY_FIVE("4:5"), + FIFTY_FOUR("5:4"), + NINE_HUNDRED_AND_SIXTEEN("9:16"), + ONE_HUNDRED_AND_SIXTY_NINE("16:9"), + TWO_HUNDRED_AND_NINETEEN("21:9"), + EIGHTEEN("1:8"), + EIGHTY_ONE("8:1"), + FOURTEEN("1:4"), + FORTY_ONE("4:1"); + + @JsonValue + private final String value; + + ImageConfigAspectRatio(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ImageConfigAspectRatio o: ImageConfigAspectRatio.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageConfigImageSize.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageConfigImageSize.java new file mode 100644 index 00000000000..a5a3bd71322 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageConfigImageSize.java @@ -0,0 +1,54 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum ImageConfigImageSize { + ONE_K("1K"), + TWO_K("2K"), + FOUR_K("4K"), + FIVE_HUNDRED_AND_TWELVE("512"); + + @JsonValue + private final String value; + + ImageConfigImageSize(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ImageConfigImageSize o: ImageConfigImageSize.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageContent.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageContent.java new file mode 100644 index 00000000000..47bd0c61ad7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageContent.java @@ -0,0 +1,338 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * ImageContent + * + *

An image content block. + */ +@SuppressWarnings("all") +public class ImageContent { + + @JsonProperty("type") + private String type; + + /** + * The image content. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("data") + private Optional data; + + /** + * The URI of the image. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + /** + * The mime type of the image. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("resolution") + private Optional resolution; + + @JsonCreator + public ImageContent( + @JsonProperty("data") Optional data, + @JsonProperty("uri") Optional uri, + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("resolution") Optional resolution) { + Utils.checkNotNull(data, "data"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(resolution, "resolution"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.data = data; + this.uri = uri; + this.mimeType = mimeType; + this.resolution = resolution; + } + + public ImageContent() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The image content. + */ + @JsonIgnore + public Optional data() { + return data; + } + + /** + * The URI of the image. + */ + @JsonIgnore + public Optional uri() { + return uri; + } + + /** + * The mime type of the image. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional resolution() { + return (Optional) resolution; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The image content. + */ + public ImageContent withData(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + + /** + * The image content. + */ + public ImageContent withData(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + /** + * The URI of the image. + */ + public ImageContent withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + /** + * The URI of the image. + */ + public ImageContent withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + /** + * The mime type of the image. + */ + public ImageContent withMimeType(ImageContentMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + /** + * The mime type of the image. + */ + public ImageContent withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + public ImageContent withResolution(MediaResolution resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = Optional.ofNullable(resolution); + return this; + } + + + public ImageContent withResolution(Optional resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = resolution; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ImageContent other = (ImageContent) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.resolution, other.resolution); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, data, uri, + mimeType, resolution); + } + + @Override + public String toString() { + return Utils.toString(ImageContent.class, + "type", type, + "data", data, + "uri", uri, + "mimeType", mimeType, + "resolution", resolution); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional data = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + private Optional resolution = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The image content. + */ + public Builder data(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + /** + * The image content. + */ + public Builder data(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + + /** + * The URI of the image. + */ + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + /** + * The URI of the image. + */ + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + /** + * The mime type of the image. + */ + public Builder mimeType(ImageContentMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + /** + * The mime type of the image. + */ + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + public Builder resolution(MediaResolution resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = Optional.ofNullable(resolution); + return this; + } + + public Builder resolution(Optional resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = resolution; + return this; + } + + public ImageContent build() { + + return new ImageContent( + data, uri, mimeType, + resolution); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"image\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageContentMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageContentMimeType.java new file mode 100644 index 00000000000..12535475c25 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageContentMimeType.java @@ -0,0 +1,63 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * ImageContentMimeType + * + *

The mime type of the image. + */ +@SuppressWarnings("all") +public enum ImageContentMimeType { + IMAGE_PNG("image/png"), + IMAGE_JPEG("image/jpeg"), + IMAGE_WEBP("image/webp"), + IMAGE_HEIC("image/heic"), + IMAGE_HEIF("image/heif"), + IMAGE_GIF("image/gif"), + IMAGE_BMP("image/bmp"), + IMAGE_TIFF("image/tiff"); + + @JsonValue + private final String value; + + ImageContentMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ImageContentMimeType o: ImageContentMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageDelta.java new file mode 100644 index 00000000000..562aa53855e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageDelta.java @@ -0,0 +1,283 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ImageDelta { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("data") + private Optional data; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("resolution") + private Optional resolution; + + @JsonCreator + public ImageDelta( + @JsonProperty("data") Optional data, + @JsonProperty("uri") Optional uri, + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("resolution") Optional resolution) { + Utils.checkNotNull(data, "data"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(resolution, "resolution"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.data = data; + this.uri = uri; + this.mimeType = mimeType; + this.resolution = resolution; + } + + public ImageDelta() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public Optional data() { + return data; + } + + @JsonIgnore + public Optional uri() { + return uri; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional resolution() { + return (Optional) resolution; + } + + public static Builder builder() { + return new Builder(); + } + + + public ImageDelta withData(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + + public ImageDelta withData(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + public ImageDelta withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + public ImageDelta withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + public ImageDelta withMimeType(ImageDeltaMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + public ImageDelta withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + public ImageDelta withResolution(MediaResolution resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = Optional.ofNullable(resolution); + return this; + } + + + public ImageDelta withResolution(Optional resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = resolution; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ImageDelta other = (ImageDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.resolution, other.resolution); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, data, uri, + mimeType, resolution); + } + + @Override + public String toString() { + return Utils.toString(ImageDelta.class, + "type", type, + "data", data, + "uri", uri, + "mimeType", mimeType, + "resolution", resolution); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional data = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + private Optional resolution = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder data(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + public Builder data(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + public Builder mimeType(ImageDeltaMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + public Builder resolution(MediaResolution resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = Optional.ofNullable(resolution); + return this; + } + + public Builder resolution(Optional resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = resolution; + return this; + } + + public ImageDelta build() { + + return new ImageDelta( + data, uri, mimeType, + resolution); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"image\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageDeltaMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageDeltaMimeType.java new file mode 100644 index 00000000000..0fb4b97ced1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageDeltaMimeType.java @@ -0,0 +1,58 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum ImageDeltaMimeType { + IMAGE_PNG("image/png"), + IMAGE_JPEG("image/jpeg"), + IMAGE_WEBP("image/webp"), + IMAGE_HEIC("image/heic"), + IMAGE_HEIF("image/heif"), + IMAGE_GIF("image/gif"), + IMAGE_BMP("image/bmp"), + IMAGE_TIFF("image/tiff"); + + @JsonValue + private final String value; + + ImageDeltaMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ImageDeltaMimeType o: ImageDeltaMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormat.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormat.java new file mode 100644 index 00000000000..38ca1f1c152 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormat.java @@ -0,0 +1,357 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * ImageResponseFormat + * + *

Configuration for image output format. + */ +@SuppressWarnings("all") +public class ImageResponseFormat { + + @JsonProperty("type") + private String type; + + /** + * The MIME type of the image output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + /** + * The delivery mode for the image output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("delivery") + private Optional delivery; + + /** + * The aspect ratio for the image output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("aspect_ratio") + private Optional aspectRatio; + + /** + * The size of the image output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("image_size") + private Optional imageSize; + + @JsonCreator + public ImageResponseFormat( + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("delivery") Optional delivery, + @JsonProperty("aspect_ratio") Optional aspectRatio, + @JsonProperty("image_size") Optional imageSize) { + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(delivery, "delivery"); + Utils.checkNotNull(aspectRatio, "aspectRatio"); + Utils.checkNotNull(imageSize, "imageSize"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.mimeType = mimeType; + this.delivery = delivery; + this.aspectRatio = aspectRatio; + this.imageSize = imageSize; + } + + public ImageResponseFormat() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The MIME type of the image output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + /** + * The delivery mode for the image output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional delivery() { + return (Optional) delivery; + } + + /** + * The aspect ratio for the image output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional aspectRatio() { + return (Optional) aspectRatio; + } + + /** + * The size of the image output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional imageSize() { + return (Optional) imageSize; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The MIME type of the image output. + */ + public ImageResponseFormat withMimeType(ImageResponseFormatMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + /** + * The MIME type of the image output. + */ + public ImageResponseFormat withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + /** + * The delivery mode for the image output. + */ + public ImageResponseFormat withDelivery(ImageResponseFormatDelivery delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = Optional.ofNullable(delivery); + return this; + } + + + /** + * The delivery mode for the image output. + */ + public ImageResponseFormat withDelivery(Optional delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = delivery; + return this; + } + + /** + * The aspect ratio for the image output. + */ + public ImageResponseFormat withAspectRatio(ImageResponseFormatAspectRatio aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = Optional.ofNullable(aspectRatio); + return this; + } + + + /** + * The aspect ratio for the image output. + */ + public ImageResponseFormat withAspectRatio(Optional aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = aspectRatio; + return this; + } + + /** + * The size of the image output. + */ + public ImageResponseFormat withImageSize(ImageResponseFormatImageSize imageSize) { + Utils.checkNotNull(imageSize, "imageSize"); + this.imageSize = Optional.ofNullable(imageSize); + return this; + } + + + /** + * The size of the image output. + */ + public ImageResponseFormat withImageSize(Optional imageSize) { + Utils.checkNotNull(imageSize, "imageSize"); + this.imageSize = imageSize; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ImageResponseFormat other = (ImageResponseFormat) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.delivery, other.delivery) && + Utils.enhancedDeepEquals(this.aspectRatio, other.aspectRatio) && + Utils.enhancedDeepEquals(this.imageSize, other.imageSize); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, mimeType, delivery, + aspectRatio, imageSize); + } + + @Override + public String toString() { + return Utils.toString(ImageResponseFormat.class, + "type", type, + "mimeType", mimeType, + "delivery", delivery, + "aspectRatio", aspectRatio, + "imageSize", imageSize); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional mimeType = Optional.empty(); + + private Optional delivery = Optional.empty(); + + private Optional aspectRatio = Optional.empty(); + + private Optional imageSize = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The MIME type of the image output. + */ + public Builder mimeType(ImageResponseFormatMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + /** + * The MIME type of the image output. + */ + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + /** + * The delivery mode for the image output. + */ + public Builder delivery(ImageResponseFormatDelivery delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = Optional.ofNullable(delivery); + return this; + } + + /** + * The delivery mode for the image output. + */ + public Builder delivery(Optional delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = delivery; + return this; + } + + + /** + * The aspect ratio for the image output. + */ + public Builder aspectRatio(ImageResponseFormatAspectRatio aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = Optional.ofNullable(aspectRatio); + return this; + } + + /** + * The aspect ratio for the image output. + */ + public Builder aspectRatio(Optional aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = aspectRatio; + return this; + } + + + /** + * The size of the image output. + */ + public Builder imageSize(ImageResponseFormatImageSize imageSize) { + Utils.checkNotNull(imageSize, "imageSize"); + this.imageSize = Optional.ofNullable(imageSize); + return this; + } + + /** + * The size of the image output. + */ + public Builder imageSize(Optional imageSize) { + Utils.checkNotNull(imageSize, "imageSize"); + this.imageSize = imageSize; + return this; + } + + public ImageResponseFormat build() { + + return new ImageResponseFormat( + mimeType, delivery, aspectRatio, + imageSize); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"image\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatAspectRatio.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatAspectRatio.java new file mode 100644 index 00000000000..7d3b256e35f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatAspectRatio.java @@ -0,0 +1,69 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * ImageResponseFormatAspectRatio + * + *

The aspect ratio for the image output. + */ +@SuppressWarnings("all") +public enum ImageResponseFormatAspectRatio { + ELEVEN("1:1"), + TWENTY_THREE("2:3"), + THIRTY_TWO("3:2"), + THIRTY_FOUR("3:4"), + FORTY_THREE("4:3"), + FORTY_FIVE("4:5"), + FIFTY_FOUR("5:4"), + NINE_HUNDRED_AND_SIXTEEN("9:16"), + ONE_HUNDRED_AND_SIXTY_NINE("16:9"), + TWO_HUNDRED_AND_NINETEEN("21:9"), + EIGHTEEN("1:8"), + EIGHTY_ONE("8:1"), + FOURTEEN("1:4"), + FORTY_ONE("4:1"); + + @JsonValue + private final String value; + + ImageResponseFormatAspectRatio(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ImageResponseFormatAspectRatio o: ImageResponseFormatAspectRatio.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatDelivery.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatDelivery.java new file mode 100644 index 00000000000..adc857e60cb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatDelivery.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * ImageResponseFormatDelivery + * + *

The delivery mode for the image output. + */ +@SuppressWarnings("all") +public enum ImageResponseFormatDelivery { + INLINE("inline"), + URI("uri"); + + @JsonValue + private final String value; + + ImageResponseFormatDelivery(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ImageResponseFormatDelivery o: ImageResponseFormatDelivery.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatImageSize.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatImageSize.java new file mode 100644 index 00000000000..b59d680f67b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatImageSize.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. +*/ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * ImageResponseFormatImageSize + * + *

The size of the image output. + */ +@SuppressWarnings("all") +public enum ImageResponseFormatImageSize { + FIVE_HUNDRED_AND_TWELVE("512"), + ONE_K("1K"), + TWO_K("2K"), + FOUR_K("4K"); + + @JsonValue + private final String value; + + ImageResponseFormatImageSize(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ImageResponseFormatImageSize o: ImageResponseFormatImageSize.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatMimeType.java new file mode 100644 index 00000000000..d9acfd71261 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ImageResponseFormatMimeType.java @@ -0,0 +1,56 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * ImageResponseFormatMimeType + * + *

The MIME type of the image output. + */ +@SuppressWarnings("all") +public enum ImageResponseFormatMimeType { + IMAGE_JPEG("image/jpeg"); + + @JsonValue + private final String value; + + ImageResponseFormatMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ImageResponseFormatMimeType o: ImageResponseFormatMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Interaction.java b/src/main/java/com/google/genai/gaos/models/interactions/Interaction.java new file mode 100644 index 00000000000..0386bad9ccb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Interaction.java @@ -0,0 +1,1758 @@ +/* +* 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.JsonIgnore; +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 java.lang.Deprecated; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * Interaction + * + *

The Interaction resource. + */ +@SuppressWarnings("all") +public class Interaction { + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("model") + private Optional model; + + /** + * The agent to interact with. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("agent") + private Optional agent; + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("id") + private Optional id; + + /** + * Required. Output only. The status of the interaction. + */ + @JsonProperty("status") + private InteractionStatus status; + + /** + * Output only. The time at which the response was created in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("created") + private Optional created; + + /** + * Output only. The time at which the response was last updated in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("updated") + private Optional updated; + + /** + * System instruction for the interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("system_instruction") + private Optional systemInstruction; + + /** + * A list of tool declarations the model may call during interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("tools") + private Optional> tools; + + /** + * Statistics on the interaction request's token usage. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("usage") + private Optional usage; + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_modalities") + private Optional> responseModalities; + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_mime_type") + @Deprecated + private Optional responseMimeType; + + /** + * The ID of the previous interaction, if any. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("previous_interaction_id") + private Optional previousInteractionId; + + /** + * Output only. The environment ID for the interaction. Only populated if environment + * config is set in the request. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("environment_id") + private Optional environmentId; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("service_tier") + private Optional serviceTier; + + /** + * Message for configuring webhook events for a request. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("webhook_config") + private Optional webhookConfig; + + /** + * Output only. The steps that make up the interaction, when included in the response. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("steps") + private Optional> steps; + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("response_format") + private Optional responseFormat; + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("environment") + private Optional environment; + + /** + * Configuration parameters for model interactions. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("generation_config") + private Optional generationConfig; + + /** + * The name of the cached content used as context to serve the prediction. + * Note: only used in explicit caching, where users can have control over + * caching (e.g. what content to cache) and enjoy guaranteed cost savings. + * Format: + * `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("cached_content") + private Optional cachedContent; + + /** + * Configuration parameters for the agent interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("agent_config") + private Optional agentConfig; + + /** + * The input for the interaction. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("input") + private Optional input; + + /** + * Concatenated text from the last model output in response to the current request. + * + *

Note: this is added by the SDK. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("output_text") + private Optional outputText; + + /** + * An image content block. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("output_image") + private Optional outputImage; + + /** + * An audio content block. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("output_audio") + private Optional outputAudio; + + /** + * A video content block. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("output_video") + private Optional outputVideo; + + @JsonCreator + public Interaction( + @JsonProperty("model") Optional model, + @JsonProperty("agent") Optional agent, + @JsonProperty("id") Optional id, + @JsonProperty("status") InteractionStatus status, + @JsonProperty("created") Optional created, + @JsonProperty("updated") Optional updated, + @JsonProperty("system_instruction") Optional systemInstruction, + @JsonProperty("tools") Optional> tools, + @JsonProperty("usage") Optional usage, + @JsonProperty("response_modalities") Optional> responseModalities, + @JsonProperty("response_mime_type") Optional responseMimeType, + @JsonProperty("previous_interaction_id") Optional previousInteractionId, + @JsonProperty("environment_id") Optional environmentId, + @JsonProperty("service_tier") Optional serviceTier, + @JsonProperty("webhook_config") Optional webhookConfig, + @JsonProperty("steps") Optional> steps, + @JsonProperty("response_format") Optional responseFormat, + @JsonProperty("environment") Optional environment, + @JsonProperty("generation_config") Optional generationConfig, + @JsonProperty("cached_content") Optional cachedContent, + @JsonProperty("agent_config") Optional agentConfig, + @JsonProperty("input") Optional input, + @JsonProperty("output_text") Optional outputText, + @JsonProperty("output_image") Optional outputImage, + @JsonProperty("output_audio") Optional outputAudio, + @JsonProperty("output_video") Optional outputVideo) { + Utils.checkNotNull(model, "model"); + Utils.checkNotNull(agent, "agent"); + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(status, "status"); + Utils.checkNotNull(created, "created"); + Utils.checkNotNull(updated, "updated"); + Utils.checkNotNull(systemInstruction, "systemInstruction"); + Utils.checkNotNull(tools, "tools"); + Utils.checkNotNull(usage, "usage"); + Utils.checkNotNull(responseModalities, "responseModalities"); + Utils.checkNotNull(responseMimeType, "responseMimeType"); + Utils.checkNotNull(previousInteractionId, "previousInteractionId"); + Utils.checkNotNull(environmentId, "environmentId"); + Utils.checkNotNull(serviceTier, "serviceTier"); + Utils.checkNotNull(webhookConfig, "webhookConfig"); + Utils.checkNotNull(steps, "steps"); + Utils.checkNotNull(responseFormat, "responseFormat"); + Utils.checkNotNull(environment, "environment"); + Utils.checkNotNull(generationConfig, "generationConfig"); + Utils.checkNotNull(cachedContent, "cachedContent"); + Utils.checkNotNull(agentConfig, "agentConfig"); + Utils.checkNotNull(input, "input"); + Utils.checkNotNull(outputText, "outputText"); + Utils.checkNotNull(outputImage, "outputImage"); + Utils.checkNotNull(outputAudio, "outputAudio"); + Utils.checkNotNull(outputVideo, "outputVideo"); + this.model = model; + this.agent = agent; + this.id = id; + this.status = status; + this.created = created; + this.updated = updated; + this.systemInstruction = systemInstruction; + this.tools = tools; + this.usage = usage; + this.responseModalities = responseModalities; + this.responseMimeType = responseMimeType; + this.previousInteractionId = previousInteractionId; + this.environmentId = environmentId; + this.serviceTier = serviceTier; + this.webhookConfig = webhookConfig; + this.steps = steps; + this.responseFormat = responseFormat; + this.environment = environment; + this.generationConfig = generationConfig; + this.cachedContent = cachedContent; + this.agentConfig = agentConfig; + this.input = input; + this.outputText = outputText; + this.outputImage = outputImage; + this.outputAudio = outputAudio; + this.outputVideo = outputVideo; + } + + public Interaction( + InteractionStatus status) { + this(Optional.empty(), Optional.empty(), Optional.empty(), + status, Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional model() { + return (Optional) model; + } + + /** + * The agent to interact with. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional agent() { + return (Optional) agent; + } + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + @JsonIgnore + public Optional id() { + return id; + } + + /** + * Required. Output only. The status of the interaction. + */ + @JsonIgnore + public InteractionStatus status() { + return status; + } + + /** + * Output only. The time at which the response was created in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + @JsonIgnore + public Optional created() { + return created; + } + + /** + * Output only. The time at which the response was last updated in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + @JsonIgnore + public Optional updated() { + return updated; + } + + /** + * System instruction for the interaction. + */ + @JsonIgnore + public Optional systemInstruction() { + return systemInstruction; + } + + /** + * A list of tool declarations the model may call during interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> tools() { + return (Optional>) tools; + } + + /** + * Statistics on the interaction request's token usage. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional usage() { + return (Optional) usage; + } + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> responseModalities() { + return (Optional>) responseModalities; + } + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + @JsonIgnore + public Optional responseMimeType() { + return responseMimeType; + } + + /** + * The ID of the previous interaction, if any. + */ + @JsonIgnore + public Optional previousInteractionId() { + return previousInteractionId; + } + + /** + * Output only. The environment ID for the interaction. Only populated if environment + * config is set in the request. + */ + @JsonIgnore + public Optional environmentId() { + return environmentId; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional serviceTier() { + return (Optional) serviceTier; + } + + /** + * Message for configuring webhook events for a request. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhookConfig() { + return (Optional) webhookConfig; + } + + /** + * Output only. The steps that make up the interaction, when included in the response. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> steps() { + return (Optional>) steps; + } + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional responseFormat() { + return (Optional) responseFormat; + } + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional environment() { + return (Optional) environment; + } + + /** + * Configuration parameters for model interactions. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional generationConfig() { + return (Optional) generationConfig; + } + + /** + * The name of the cached content used as context to serve the prediction. + * Note: only used in explicit caching, where users can have control over + * caching (e.g. what content to cache) and enjoy guaranteed cost savings. + * Format: + * `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + */ + @JsonIgnore + public Optional cachedContent() { + return cachedContent; + } + + /** + * Configuration parameters for the agent interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional agentConfig() { + return (Optional) agentConfig; + } + + /** + * The input for the interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional input() { + return (Optional) input; + } + + /** + * Concatenated text from the last model output in response to the current request. + * + *

Note: this is added by the SDK. + */ + @JsonIgnore + public Optional outputText() { + return outputText; + } + + /** + * An image content block. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional outputImage() { + return (Optional) outputImage; + } + + /** + * An audio content block. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional outputAudio() { + return (Optional) outputAudio; + } + + /** + * A video content block. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional outputVideo() { + return (Optional) outputVideo; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + public Interaction withModel(Model model) { + Utils.checkNotNull(model, "model"); + this.model = Optional.ofNullable(model); + return this; + } + + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + public Interaction withModel(Optional model) { + Utils.checkNotNull(model, "model"); + this.model = model; + return this; + } + + /** + * The agent to interact with. + */ + public Interaction withAgent(AgentOption agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + + /** + * The agent to interact with. + */ + public Interaction withAgent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + public Interaction withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = Optional.ofNullable(id); + return this; + } + + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + public Interaction withId(Optional id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * Required. Output only. The status of the interaction. + */ + public Interaction withStatus(InteractionStatus status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + /** + * Output only. The time at which the response was created in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + public Interaction withCreated(String created) { + Utils.checkNotNull(created, "created"); + this.created = Optional.ofNullable(created); + return this; + } + + + /** + * Output only. The time at which the response was created in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + public Interaction withCreated(Optional created) { + Utils.checkNotNull(created, "created"); + this.created = created; + return this; + } + + /** + * Output only. The time at which the response was last updated in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + public Interaction withUpdated(String updated) { + Utils.checkNotNull(updated, "updated"); + this.updated = Optional.ofNullable(updated); + return this; + } + + + /** + * Output only. The time at which the response was last updated in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + public Interaction withUpdated(Optional updated) { + Utils.checkNotNull(updated, "updated"); + this.updated = updated; + return this; + } + + /** + * System instruction for the interaction. + */ + public Interaction withSystemInstruction(String systemInstruction) { + Utils.checkNotNull(systemInstruction, "systemInstruction"); + this.systemInstruction = Optional.ofNullable(systemInstruction); + return this; + } + + + /** + * System instruction for the interaction. + */ + public Interaction withSystemInstruction(Optional systemInstruction) { + Utils.checkNotNull(systemInstruction, "systemInstruction"); + this.systemInstruction = systemInstruction; + return this; + } + + /** + * A list of tool declarations the model may call during interaction. + */ + public Interaction withTools(List tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = Optional.ofNullable(tools); + return this; + } + + + /** + * A list of tool declarations the model may call during interaction. + */ + public Interaction withTools(Optional> tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = tools; + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Interaction withUsage(Usage usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = Optional.ofNullable(usage); + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public Interaction withUsage(Optional usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = usage; + return this; + } + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public Interaction withResponseModalities(List responseModalities) { + Utils.checkNotNull(responseModalities, "responseModalities"); + this.responseModalities = Optional.ofNullable(responseModalities); + return this; + } + + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public Interaction withResponseModalities(Optional> responseModalities) { + Utils.checkNotNull(responseModalities, "responseModalities"); + this.responseModalities = responseModalities; + return this; + } + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Interaction withResponseMimeType(String responseMimeType) { + Utils.checkNotNull(responseMimeType, "responseMimeType"); + this.responseMimeType = Optional.ofNullable(responseMimeType); + return this; + } + + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Interaction withResponseMimeType(Optional responseMimeType) { + Utils.checkNotNull(responseMimeType, "responseMimeType"); + this.responseMimeType = responseMimeType; + return this; + } + + /** + * The ID of the previous interaction, if any. + */ + public Interaction withPreviousInteractionId(String previousInteractionId) { + Utils.checkNotNull(previousInteractionId, "previousInteractionId"); + this.previousInteractionId = Optional.ofNullable(previousInteractionId); + return this; + } + + + /** + * The ID of the previous interaction, if any. + */ + public Interaction withPreviousInteractionId(Optional previousInteractionId) { + Utils.checkNotNull(previousInteractionId, "previousInteractionId"); + this.previousInteractionId = previousInteractionId; + return this; + } + + /** + * Output only. The environment ID for the interaction. Only populated if environment + * config is set in the request. + */ + public Interaction withEnvironmentId(String environmentId) { + Utils.checkNotNull(environmentId, "environmentId"); + this.environmentId = Optional.ofNullable(environmentId); + return this; + } + + + /** + * Output only. The environment ID for the interaction. Only populated if environment + * config is set in the request. + */ + public Interaction withEnvironmentId(Optional environmentId) { + Utils.checkNotNull(environmentId, "environmentId"); + this.environmentId = environmentId; + return this; + } + + public Interaction withServiceTier(ServiceTier serviceTier) { + Utils.checkNotNull(serviceTier, "serviceTier"); + this.serviceTier = Optional.ofNullable(serviceTier); + return this; + } + + + public Interaction withServiceTier(Optional serviceTier) { + Utils.checkNotNull(serviceTier, "serviceTier"); + this.serviceTier = serviceTier; + return this; + } + + /** + * Message for configuring webhook events for a request. + */ + public Interaction withWebhookConfig(WebhookConfig webhookConfig) { + Utils.checkNotNull(webhookConfig, "webhookConfig"); + this.webhookConfig = Optional.ofNullable(webhookConfig); + return this; + } + + + /** + * Message for configuring webhook events for a request. + */ + public Interaction withWebhookConfig(Optional webhookConfig) { + Utils.checkNotNull(webhookConfig, "webhookConfig"); + this.webhookConfig = webhookConfig; + return this; + } + + /** + * Output only. The steps that make up the interaction, when included in the response. + */ + public Interaction withSteps(List steps) { + Utils.checkNotNull(steps, "steps"); + this.steps = Optional.ofNullable(steps); + return this; + } + + + /** + * Output only. The steps that make up the interaction, when included in the response. + */ + public Interaction withSteps(Optional> steps) { + Utils.checkNotNull(steps, "steps"); + this.steps = steps; + return this; + } + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public Interaction withResponseFormat(InteractionResponseFormat responseFormat) { + Utils.checkNotNull(responseFormat, "responseFormat"); + this.responseFormat = Optional.ofNullable(responseFormat); + return this; + } + + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public Interaction withResponseFormat(Optional responseFormat) { + Utils.checkNotNull(responseFormat, "responseFormat"); + this.responseFormat = responseFormat; + return this; + } + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public Interaction withEnvironment(InteractionEnvironment environment) { + Utils.checkNotNull(environment, "environment"); + this.environment = Optional.ofNullable(environment); + return this; + } + + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public Interaction withEnvironment(Optional environment) { + Utils.checkNotNull(environment, "environment"); + this.environment = environment; + return this; + } + + /** + * Configuration parameters for model interactions. + */ + public Interaction withGenerationConfig(GenerationConfig generationConfig) { + Utils.checkNotNull(generationConfig, "generationConfig"); + this.generationConfig = Optional.ofNullable(generationConfig); + return this; + } + + + /** + * Configuration parameters for model interactions. + */ + public Interaction withGenerationConfig(Optional generationConfig) { + Utils.checkNotNull(generationConfig, "generationConfig"); + this.generationConfig = generationConfig; + return this; + } + + /** + * The name of the cached content used as context to serve the prediction. + * Note: only used in explicit caching, where users can have control over + * caching (e.g. what content to cache) and enjoy guaranteed cost savings. + * Format: + * `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + */ + public Interaction withCachedContent(String cachedContent) { + Utils.checkNotNull(cachedContent, "cachedContent"); + this.cachedContent = Optional.ofNullable(cachedContent); + return this; + } + + + /** + * The name of the cached content used as context to serve the prediction. + * Note: only used in explicit caching, where users can have control over + * caching (e.g. what content to cache) and enjoy guaranteed cost savings. + * Format: + * `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + */ + public Interaction withCachedContent(Optional cachedContent) { + Utils.checkNotNull(cachedContent, "cachedContent"); + this.cachedContent = cachedContent; + return this; + } + + /** + * Configuration parameters for the agent interaction. + */ + public Interaction withAgentConfig(InteractionAgentConfig agentConfig) { + Utils.checkNotNull(agentConfig, "agentConfig"); + this.agentConfig = Optional.ofNullable(agentConfig); + return this; + } + + + /** + * Configuration parameters for the agent interaction. + */ + public Interaction withAgentConfig(Optional agentConfig) { + Utils.checkNotNull(agentConfig, "agentConfig"); + this.agentConfig = agentConfig; + return this; + } + + /** + * The input for the interaction. + */ + public Interaction withInput(InteractionsInput input) { + Utils.checkNotNull(input, "input"); + this.input = Optional.ofNullable(input); + return this; + } + + + /** + * The input for the interaction. + */ + public Interaction withInput(Optional input) { + Utils.checkNotNull(input, "input"); + this.input = input; + return this; + } + + /** + * Concatenated text from the last model output in response to the current request. + * + *

Note: this is added by the SDK. + */ + public Interaction withOutputText(String outputText) { + Utils.checkNotNull(outputText, "outputText"); + this.outputText = Optional.ofNullable(outputText); + return this; + } + + + /** + * Concatenated text from the last model output in response to the current request. + * + *

Note: this is added by the SDK. + */ + public Interaction withOutputText(Optional outputText) { + Utils.checkNotNull(outputText, "outputText"); + this.outputText = outputText; + return this; + } + + /** + * An image content block. + */ + public Interaction withOutputImage(ImageContent outputImage) { + Utils.checkNotNull(outputImage, "outputImage"); + this.outputImage = Optional.ofNullable(outputImage); + return this; + } + + + /** + * An image content block. + */ + public Interaction withOutputImage(Optional outputImage) { + Utils.checkNotNull(outputImage, "outputImage"); + this.outputImage = outputImage; + return this; + } + + /** + * An audio content block. + */ + public Interaction withOutputAudio(AudioContent outputAudio) { + Utils.checkNotNull(outputAudio, "outputAudio"); + this.outputAudio = Optional.ofNullable(outputAudio); + return this; + } + + + /** + * An audio content block. + */ + public Interaction withOutputAudio(Optional outputAudio) { + Utils.checkNotNull(outputAudio, "outputAudio"); + this.outputAudio = outputAudio; + return this; + } + + /** + * A video content block. + */ + public Interaction withOutputVideo(VideoContent outputVideo) { + Utils.checkNotNull(outputVideo, "outputVideo"); + this.outputVideo = Optional.ofNullable(outputVideo); + return this; + } + + + /** + * A video content block. + */ + public Interaction withOutputVideo(Optional outputVideo) { + Utils.checkNotNull(outputVideo, "outputVideo"); + this.outputVideo = outputVideo; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Interaction other = (Interaction) o; + return + Utils.enhancedDeepEquals(this.model, other.model) && + Utils.enhancedDeepEquals(this.agent, other.agent) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.status, other.status) && + Utils.enhancedDeepEquals(this.created, other.created) && + Utils.enhancedDeepEquals(this.updated, other.updated) && + Utils.enhancedDeepEquals(this.systemInstruction, other.systemInstruction) && + Utils.enhancedDeepEquals(this.tools, other.tools) && + Utils.enhancedDeepEquals(this.usage, other.usage) && + Utils.enhancedDeepEquals(this.responseModalities, other.responseModalities) && + Utils.enhancedDeepEquals(this.responseMimeType, other.responseMimeType) && + Utils.enhancedDeepEquals(this.previousInteractionId, other.previousInteractionId) && + Utils.enhancedDeepEquals(this.environmentId, other.environmentId) && + Utils.enhancedDeepEquals(this.serviceTier, other.serviceTier) && + Utils.enhancedDeepEquals(this.webhookConfig, other.webhookConfig) && + Utils.enhancedDeepEquals(this.steps, other.steps) && + Utils.enhancedDeepEquals(this.responseFormat, other.responseFormat) && + Utils.enhancedDeepEquals(this.environment, other.environment) && + Utils.enhancedDeepEquals(this.generationConfig, other.generationConfig) && + Utils.enhancedDeepEquals(this.cachedContent, other.cachedContent) && + Utils.enhancedDeepEquals(this.agentConfig, other.agentConfig) && + Utils.enhancedDeepEquals(this.input, other.input) && + Utils.enhancedDeepEquals(this.outputText, other.outputText) && + Utils.enhancedDeepEquals(this.outputImage, other.outputImage) && + Utils.enhancedDeepEquals(this.outputAudio, other.outputAudio) && + Utils.enhancedDeepEquals(this.outputVideo, other.outputVideo); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + model, agent, id, + status, created, updated, + systemInstruction, tools, usage, + responseModalities, responseMimeType, previousInteractionId, + environmentId, serviceTier, webhookConfig, + steps, responseFormat, environment, + generationConfig, cachedContent, agentConfig, + input, outputText, outputImage, + outputAudio, outputVideo); + } + + @Override + public String toString() { + return Utils.toString(Interaction.class, + "model", model, + "agent", agent, + "id", id, + "status", status, + "created", created, + "updated", updated, + "systemInstruction", systemInstruction, + "tools", tools, + "usage", usage, + "responseModalities", responseModalities, + "responseMimeType", responseMimeType, + "previousInteractionId", previousInteractionId, + "environmentId", environmentId, + "serviceTier", serviceTier, + "webhookConfig", webhookConfig, + "steps", steps, + "responseFormat", responseFormat, + "environment", environment, + "generationConfig", generationConfig, + "cachedContent", cachedContent, + "agentConfig", agentConfig, + "input", input, + "outputText", outputText, + "outputImage", outputImage, + "outputAudio", outputAudio, + "outputVideo", outputVideo); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional model = Optional.empty(); + + private Optional agent = Optional.empty(); + + private Optional id; + + private InteractionStatus status; + + private Optional created = Optional.empty(); + + private Optional updated = Optional.empty(); + + private Optional systemInstruction = Optional.empty(); + + private Optional> tools = Optional.empty(); + + private Optional usage = Optional.empty(); + + private Optional> responseModalities = Optional.empty(); + + @Deprecated + private Optional responseMimeType = Optional.empty(); + + private Optional previousInteractionId = Optional.empty(); + + private Optional environmentId = Optional.empty(); + + private Optional serviceTier = Optional.empty(); + + private Optional webhookConfig = Optional.empty(); + + private Optional> steps = Optional.empty(); + + private Optional responseFormat = Optional.empty(); + + private Optional environment = Optional.empty(); + + private Optional generationConfig = Optional.empty(); + + private Optional cachedContent = Optional.empty(); + + private Optional agentConfig = Optional.empty(); + + private Optional input = Optional.empty(); + + private Optional outputText = Optional.empty(); + + private Optional outputImage = Optional.empty(); + + private Optional outputAudio = Optional.empty(); + + private Optional outputVideo = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + public Builder model(Model model) { + Utils.checkNotNull(model, "model"); + this.model = Optional.ofNullable(model); + return this; + } + + /** + * The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ + public Builder model(Optional model) { + Utils.checkNotNull(model, "model"); + this.model = model; + return this; + } + + + /** + * The agent to interact with. + */ + public Builder agent(AgentOption agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + /** + * The agent to interact with. + */ + public Builder agent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = Optional.ofNullable(id); + return this; + } + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + public Builder id(Optional id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * Required. Output only. The status of the interaction. + */ + public Builder status(InteractionStatus status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + + /** + * Output only. The time at which the response was created in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + public Builder created(String created) { + Utils.checkNotNull(created, "created"); + this.created = Optional.ofNullable(created); + return this; + } + + /** + * Output only. The time at which the response was created in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + public Builder created(Optional created) { + Utils.checkNotNull(created, "created"); + this.created = created; + return this; + } + + + /** + * Output only. The time at which the response was last updated in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + public Builder updated(String updated) { + Utils.checkNotNull(updated, "updated"); + this.updated = Optional.ofNullable(updated); + return this; + } + + /** + * Output only. The time at which the response was last updated in ISO 8601 format + * (YYYY-MM-DDThh:mm:ssZ). + */ + public Builder updated(Optional updated) { + Utils.checkNotNull(updated, "updated"); + this.updated = updated; + return this; + } + + + /** + * System instruction for the interaction. + */ + public Builder systemInstruction(String systemInstruction) { + Utils.checkNotNull(systemInstruction, "systemInstruction"); + this.systemInstruction = Optional.ofNullable(systemInstruction); + return this; + } + + /** + * System instruction for the interaction. + */ + public Builder systemInstruction(Optional systemInstruction) { + Utils.checkNotNull(systemInstruction, "systemInstruction"); + this.systemInstruction = systemInstruction; + return this; + } + + + /** + * A list of tool declarations the model may call during interaction. + */ + public Builder tools(List tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = Optional.ofNullable(tools); + return this; + } + + /** + * A list of tool declarations the model may call during interaction. + */ + public Builder tools(Optional> tools) { + Utils.checkNotNull(tools, "tools"); + this.tools = tools; + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public Builder usage(Usage usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = Optional.ofNullable(usage); + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Builder usage(Optional usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = usage; + return this; + } + + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public Builder responseModalities(List responseModalities) { + Utils.checkNotNull(responseModalities, "responseModalities"); + this.responseModalities = Optional.ofNullable(responseModalities); + return this; + } + + /** + * The requested modalities of the response (TEXT, IMAGE, AUDIO). + */ + public Builder responseModalities(Optional> responseModalities) { + Utils.checkNotNull(responseModalities, "responseModalities"); + this.responseModalities = responseModalities; + return this; + } + + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder responseMimeType(String responseMimeType) { + Utils.checkNotNull(responseMimeType, "responseMimeType"); + this.responseMimeType = Optional.ofNullable(responseMimeType); + return this; + } + + /** + * The mime type of the response. This is required if response_format is set. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder responseMimeType(Optional responseMimeType) { + Utils.checkNotNull(responseMimeType, "responseMimeType"); + this.responseMimeType = responseMimeType; + return this; + } + + + /** + * The ID of the previous interaction, if any. + */ + public Builder previousInteractionId(String previousInteractionId) { + Utils.checkNotNull(previousInteractionId, "previousInteractionId"); + this.previousInteractionId = Optional.ofNullable(previousInteractionId); + return this; + } + + /** + * The ID of the previous interaction, if any. + */ + public Builder previousInteractionId(Optional previousInteractionId) { + Utils.checkNotNull(previousInteractionId, "previousInteractionId"); + this.previousInteractionId = previousInteractionId; + return this; + } + + + /** + * Output only. The environment ID for the interaction. Only populated if environment + * config is set in the request. + */ + public Builder environmentId(String environmentId) { + Utils.checkNotNull(environmentId, "environmentId"); + this.environmentId = Optional.ofNullable(environmentId); + return this; + } + + /** + * Output only. The environment ID for the interaction. Only populated if environment + * config is set in the request. + */ + public Builder environmentId(Optional environmentId) { + Utils.checkNotNull(environmentId, "environmentId"); + this.environmentId = environmentId; + return this; + } + + + public Builder serviceTier(ServiceTier serviceTier) { + Utils.checkNotNull(serviceTier, "serviceTier"); + this.serviceTier = Optional.ofNullable(serviceTier); + return this; + } + + public Builder serviceTier(Optional serviceTier) { + Utils.checkNotNull(serviceTier, "serviceTier"); + this.serviceTier = serviceTier; + return this; + } + + + /** + * Message for configuring webhook events for a request. + */ + public Builder webhookConfig(WebhookConfig webhookConfig) { + Utils.checkNotNull(webhookConfig, "webhookConfig"); + this.webhookConfig = Optional.ofNullable(webhookConfig); + return this; + } + + /** + * Message for configuring webhook events for a request. + */ + public Builder webhookConfig(Optional webhookConfig) { + Utils.checkNotNull(webhookConfig, "webhookConfig"); + this.webhookConfig = webhookConfig; + return this; + } + + + /** + * Output only. The steps that make up the interaction, when included in the response. + */ + public Builder steps(List steps) { + Utils.checkNotNull(steps, "steps"); + this.steps = Optional.ofNullable(steps); + return this; + } + + /** + * Output only. The steps that make up the interaction, when included in the response. + */ + public Builder steps(Optional> steps) { + Utils.checkNotNull(steps, "steps"); + this.steps = steps; + return this; + } + + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public Builder responseFormat(InteractionResponseFormat responseFormat) { + Utils.checkNotNull(responseFormat, "responseFormat"); + this.responseFormat = Optional.ofNullable(responseFormat); + return this; + } + + /** + * Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ + public Builder responseFormat(Optional responseFormat) { + Utils.checkNotNull(responseFormat, "responseFormat"); + this.responseFormat = responseFormat; + return this; + } + + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public Builder environment(InteractionEnvironment environment) { + Utils.checkNotNull(environment, "environment"); + this.environment = Optional.ofNullable(environment); + return this; + } + + /** + * The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ + public Builder environment(Optional environment) { + Utils.checkNotNull(environment, "environment"); + this.environment = environment; + return this; + } + + + /** + * Configuration parameters for model interactions. + */ + public Builder generationConfig(GenerationConfig generationConfig) { + Utils.checkNotNull(generationConfig, "generationConfig"); + this.generationConfig = Optional.ofNullable(generationConfig); + return this; + } + + /** + * Configuration parameters for model interactions. + */ + public Builder generationConfig(Optional generationConfig) { + Utils.checkNotNull(generationConfig, "generationConfig"); + this.generationConfig = generationConfig; + return this; + } + + + /** + * The name of the cached content used as context to serve the prediction. + * Note: only used in explicit caching, where users can have control over + * caching (e.g. what content to cache) and enjoy guaranteed cost savings. + * Format: + * `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + */ + public Builder cachedContent(String cachedContent) { + Utils.checkNotNull(cachedContent, "cachedContent"); + this.cachedContent = Optional.ofNullable(cachedContent); + return this; + } + + /** + * The name of the cached content used as context to serve the prediction. + * Note: only used in explicit caching, where users can have control over + * caching (e.g. what content to cache) and enjoy guaranteed cost savings. + * Format: + * `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + */ + public Builder cachedContent(Optional cachedContent) { + Utils.checkNotNull(cachedContent, "cachedContent"); + this.cachedContent = cachedContent; + return this; + } + + + /** + * Configuration parameters for the agent interaction. + */ + public Builder agentConfig(InteractionAgentConfig agentConfig) { + Utils.checkNotNull(agentConfig, "agentConfig"); + this.agentConfig = Optional.ofNullable(agentConfig); + return this; + } + + /** + * Configuration parameters for the agent interaction. + */ + public Builder agentConfig(Optional agentConfig) { + Utils.checkNotNull(agentConfig, "agentConfig"); + this.agentConfig = agentConfig; + return this; + } + + + /** + * The input for the interaction. + */ + public Builder input(InteractionsInput input) { + Utils.checkNotNull(input, "input"); + this.input = Optional.ofNullable(input); + return this; + } + + /** + * The input for the interaction. + */ + public Builder input(Optional input) { + Utils.checkNotNull(input, "input"); + this.input = input; + return this; + } + + + /** + * Concatenated text from the last model output in response to the current request. + * + *

Note: this is added by the SDK. + */ + public Builder outputText(String outputText) { + Utils.checkNotNull(outputText, "outputText"); + this.outputText = Optional.ofNullable(outputText); + return this; + } + + /** + * Concatenated text from the last model output in response to the current request. + * + *

Note: this is added by the SDK. + */ + public Builder outputText(Optional outputText) { + Utils.checkNotNull(outputText, "outputText"); + this.outputText = outputText; + return this; + } + + + /** + * An image content block. + */ + public Builder outputImage(ImageContent outputImage) { + Utils.checkNotNull(outputImage, "outputImage"); + this.outputImage = Optional.ofNullable(outputImage); + return this; + } + + /** + * An image content block. + */ + public Builder outputImage(Optional outputImage) { + Utils.checkNotNull(outputImage, "outputImage"); + this.outputImage = outputImage; + return this; + } + + + /** + * An audio content block. + */ + public Builder outputAudio(AudioContent outputAudio) { + Utils.checkNotNull(outputAudio, "outputAudio"); + this.outputAudio = Optional.ofNullable(outputAudio); + return this; + } + + /** + * An audio content block. + */ + public Builder outputAudio(Optional outputAudio) { + Utils.checkNotNull(outputAudio, "outputAudio"); + this.outputAudio = outputAudio; + return this; + } + + + /** + * A video content block. + */ + public Builder outputVideo(VideoContent outputVideo) { + Utils.checkNotNull(outputVideo, "outputVideo"); + this.outputVideo = Optional.ofNullable(outputVideo); + return this; + } + + /** + * A video content block. + */ + public Builder outputVideo(Optional outputVideo) { + Utils.checkNotNull(outputVideo, "outputVideo"); + this.outputVideo = outputVideo; + return this; + } + + public Interaction build() { + if (id == null) { + id = _SINGLETON_VALUE_Id.value(); + } + + return new Interaction( + model, agent, id, + status, created, updated, + systemInstruction, tools, usage, + responseModalities, responseMimeType, previousInteractionId, + environmentId, serviceTier, webhookConfig, + steps, responseFormat, environment, + generationConfig, cachedContent, agentConfig, + input, outputText, outputImage, + outputAudio, outputVideo); + } + + + private static final LazySingletonValue> _SINGLETON_VALUE_Id = + new LazySingletonValue<>( + "id", + "\"\"", + new TypeReference>() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionAgentConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionAgentConfig.java new file mode 100644 index 00000000000..7ad41aac1f5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionAgentConfig.java @@ -0,0 +1,116 @@ +/* +* 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.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; + +/** + * InteractionAgentConfig + * + *

Configuration parameters for the agent interaction. + */ +@JsonDeserialize(using = InteractionAgentConfig._Deserializer.class) +@SuppressWarnings("all") +public class InteractionAgentConfig { + + @JsonValue + private final TypedObject value; + + private InteractionAgentConfig(TypedObject value) { + this.value = value; + } + + public static InteractionAgentConfig of(DynamicAgentConfig value) { + Utils.checkNotNull(value, "value"); + return new InteractionAgentConfig(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionAgentConfig of(DeepResearchAgentConfig value) { + Utils.checkNotNull(value, "value"); + return new InteractionAgentConfig(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.DynamicAgentConfig}
  • + *
  • {@code com.google.genai.gaos.models.interactions.DeepResearchAgentConfig}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionAgentConfig other = (InteractionAgentConfig) 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(InteractionAgentConfig.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(InteractionAgentConfig.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionCompletedEvent.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionCompletedEvent.java new file mode 100644 index 00000000000..0a902e79d52 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionCompletedEvent.java @@ -0,0 +1,266 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class InteractionCompletedEvent { + + @JsonProperty("event_type") + private String eventType; + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("event_id") + private Optional eventId; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata") + private Optional metadata; + + /** + * Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ + @JsonProperty("interaction") + private InteractionSseEventInteraction interaction; + + @JsonCreator + public InteractionCompletedEvent( + @JsonProperty("event_id") Optional eventId, + @JsonProperty("metadata") Optional metadata, + @JsonProperty("interaction") InteractionSseEventInteraction interaction) { + Utils.checkNotNull(eventId, "eventId"); + Utils.checkNotNull(metadata, "metadata"); + Utils.checkNotNull(interaction, "interaction"); + this.eventType = Builder._SINGLETON_VALUE_EventType.value(); + this.eventId = eventId; + this.metadata = metadata; + this.interaction = interaction; + } + + public InteractionCompletedEvent( + InteractionSseEventInteraction interaction) { + this(Optional.empty(), Optional.empty(), interaction); + } + + @JsonIgnore + public String eventType() { + return eventType; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonIgnore + public Optional eventId() { + return eventId; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional metadata() { + return (Optional) metadata; + } + + /** + * Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ + @JsonIgnore + public InteractionSseEventInteraction interaction() { + return interaction; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public InteractionCompletedEvent withEventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public InteractionCompletedEvent withEventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + public InteractionCompletedEvent withMetadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + + public InteractionCompletedEvent withMetadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + /** + * Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ + public InteractionCompletedEvent withInteraction(InteractionSseEventInteraction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionCompletedEvent other = (InteractionCompletedEvent) o; + return + Utils.enhancedDeepEquals(this.eventType, other.eventType) && + Utils.enhancedDeepEquals(this.eventId, other.eventId) && + Utils.enhancedDeepEquals(this.metadata, other.metadata) && + Utils.enhancedDeepEquals(this.interaction, other.interaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + eventType, eventId, metadata, + interaction); + } + + @Override + public String toString() { + return Utils.toString(InteractionCompletedEvent.class, + "eventType", eventType, + "eventId", eventId, + "metadata", metadata, + "interaction", interaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional eventId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private InteractionSseEventInteraction interaction; + + private Builder() { + // force use of static builder() method + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + + public Builder metadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public Builder metadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + + /** + * Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ + public Builder interaction(InteractionSseEventInteraction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + public InteractionCompletedEvent build() { + + return new InteractionCompletedEvent( + eventId, metadata, interaction); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_EventType = + new LazySingletonValue<>( + "event_type", + "\"interaction.completed\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionCreatedEvent.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionCreatedEvent.java new file mode 100644 index 00000000000..07e08c2dda2 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionCreatedEvent.java @@ -0,0 +1,266 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class InteractionCreatedEvent { + + @JsonProperty("event_type") + private String eventType; + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("event_id") + private Optional eventId; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata") + private Optional metadata; + + /** + * Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ + @JsonProperty("interaction") + private InteractionSseEventInteraction interaction; + + @JsonCreator + public InteractionCreatedEvent( + @JsonProperty("event_id") Optional eventId, + @JsonProperty("metadata") Optional metadata, + @JsonProperty("interaction") InteractionSseEventInteraction interaction) { + Utils.checkNotNull(eventId, "eventId"); + Utils.checkNotNull(metadata, "metadata"); + Utils.checkNotNull(interaction, "interaction"); + this.eventType = Builder._SINGLETON_VALUE_EventType.value(); + this.eventId = eventId; + this.metadata = metadata; + this.interaction = interaction; + } + + public InteractionCreatedEvent( + InteractionSseEventInteraction interaction) { + this(Optional.empty(), Optional.empty(), interaction); + } + + @JsonIgnore + public String eventType() { + return eventType; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonIgnore + public Optional eventId() { + return eventId; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional metadata() { + return (Optional) metadata; + } + + /** + * Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ + @JsonIgnore + public InteractionSseEventInteraction interaction() { + return interaction; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public InteractionCreatedEvent withEventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public InteractionCreatedEvent withEventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + public InteractionCreatedEvent withMetadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + + public InteractionCreatedEvent withMetadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + /** + * Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ + public InteractionCreatedEvent withInteraction(InteractionSseEventInteraction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionCreatedEvent other = (InteractionCreatedEvent) o; + return + Utils.enhancedDeepEquals(this.eventType, other.eventType) && + Utils.enhancedDeepEquals(this.eventId, other.eventId) && + Utils.enhancedDeepEquals(this.metadata, other.metadata) && + Utils.enhancedDeepEquals(this.interaction, other.interaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + eventType, eventId, metadata, + interaction); + } + + @Override + public String toString() { + return Utils.toString(InteractionCreatedEvent.class, + "eventType", eventType, + "eventId", eventId, + "metadata", metadata, + "interaction", interaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional eventId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private InteractionSseEventInteraction interaction; + + private Builder() { + // force use of static builder() method + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + + public Builder metadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public Builder metadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + + /** + * Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ + public Builder interaction(InteractionSseEventInteraction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + public InteractionCreatedEvent build() { + + return new InteractionCreatedEvent( + eventId, metadata, interaction); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_EventType = + new LazySingletonValue<>( + "event_type", + "\"interaction.created\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionEnvironment.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionEnvironment.java new file mode 100644 index 00000000000..d4413d883ae --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionEnvironment.java @@ -0,0 +1,117 @@ +/* +* 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.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; + +/** + * InteractionEnvironment + * + *

The environment configuration for the interaction. Can be an object specifying remote environment + * sources or a string referencing an existing environment ID. + */ +@JsonDeserialize(using = InteractionEnvironment._Deserializer.class) +@SuppressWarnings("all") +public class InteractionEnvironment { + + @JsonValue + private final TypedObject value; + + private InteractionEnvironment(TypedObject value) { + this.value = value; + } + + public static InteractionEnvironment of(String value) { + Utils.checkNotNull(value, "value"); + return new InteractionEnvironment(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionEnvironment of(Environment value) { + Utils.checkNotNull(value, "value"); + return new InteractionEnvironment(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code java.lang.String}
  • + *
  • {@code com.google.genai.gaos.models.interactions.Environment}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionEnvironment other = (InteractionEnvironment) 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(InteractionEnvironment.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(InteractionEnvironment.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionResponseFormat.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionResponseFormat.java new file mode 100644 index 00000000000..a2c2ac6f8fe --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionResponseFormat.java @@ -0,0 +1,118 @@ +/* +* 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.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.List; + +/** + * InteractionResponseFormat + * + *

Enforces that the generated response is a JSON object that complies with the JSON schema specified + * in this field. + */ +@JsonDeserialize(using = InteractionResponseFormat._Deserializer.class) +@SuppressWarnings("all") +public class InteractionResponseFormat { + + @JsonValue + private final TypedObject value; + + private InteractionResponseFormat(TypedObject value) { + this.value = value; + } + + public static InteractionResponseFormat of(List value) { + Utils.checkNotNull(value, "value"); + return new InteractionResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionResponseFormat of(ResponseFormat value) { + Utils.checkNotNull(value, "value"); + return new InteractionResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code java.util.List}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ResponseFormat}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionResponseFormat other = (InteractionResponseFormat) 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(InteractionResponseFormat.class, false, + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(InteractionResponseFormat.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionSSEEvent.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionSSEEvent.java new file mode 100644 index 00000000000..e5d856faae7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionSSEEvent.java @@ -0,0 +1,146 @@ +/* +* 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.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; + +@JsonDeserialize(using = InteractionSSEEvent._Deserializer.class) +@SuppressWarnings("all") +public class InteractionSSEEvent { + + @JsonValue + private final TypedObject value; + + private InteractionSSEEvent(TypedObject value) { + this.value = value; + } + + public static InteractionSSEEvent of(InteractionCreatedEvent value) { + Utils.checkNotNull(value, "value"); + return new InteractionSSEEvent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionSSEEvent of(InteractionCompletedEvent value) { + Utils.checkNotNull(value, "value"); + return new InteractionSSEEvent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionSSEEvent of(InteractionStatusUpdate value) { + Utils.checkNotNull(value, "value"); + return new InteractionSSEEvent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionSSEEvent of(ErrorEvent value) { + Utils.checkNotNull(value, "value"); + return new InteractionSSEEvent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionSSEEvent of(StepStart value) { + Utils.checkNotNull(value, "value"); + return new InteractionSSEEvent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionSSEEvent of(StepDelta value) { + Utils.checkNotNull(value, "value"); + return new InteractionSSEEvent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionSSEEvent of(StepStop value) { + Utils.checkNotNull(value, "value"); + return new InteractionSSEEvent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *
    + *
  • {@code com.google.genai.gaos.models.interactions.InteractionCreatedEvent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.InteractionCompletedEvent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.InteractionStatusUpdate}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ErrorEvent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.StepStart}
  • + *
  • {@code com.google.genai.gaos.models.interactions.StepDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.StepStop}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionSSEEvent other = (InteractionSSEEvent) 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(InteractionSSEEvent.class, false, + 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), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(InteractionSSEEvent.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionSSEStreamEvent.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionSSEStreamEvent.java new file mode 100644 index 00000000000..5629ca9874e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionSSEStreamEvent.java @@ -0,0 +1,107 @@ +/* +* 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.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + + +@SuppressWarnings("all") +public class InteractionSSEStreamEvent { + + @JsonProperty("data") + private InteractionSSEEvent data; + + @JsonCreator + public InteractionSSEStreamEvent( + @JsonProperty("data") InteractionSSEEvent data) { + Utils.checkNotNull(data, "data"); + this.data = data; + } + + @JsonIgnore + public InteractionSSEEvent data() { + return data; + } + + public static Builder builder() { + return new Builder(); + } + + + public InteractionSSEStreamEvent withData(InteractionSSEEvent data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionSSEStreamEvent other = (InteractionSSEStreamEvent) o; + return + Utils.enhancedDeepEquals(this.data, other.data); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + data); + } + + @Override + public String toString() { + return Utils.toString(InteractionSSEStreamEvent.class, + "data", data); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private InteractionSSEEvent data; + + private Builder() { + // force use of static builder() method + } + + + public Builder data(InteractionSSEEvent data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + public InteractionSSEStreamEvent build() { + + return new InteractionSSEStreamEvent( + data); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionSseEventInteraction.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionSseEventInteraction.java new file mode 100644 index 00000000000..f5d9354b5be --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionSseEventInteraction.java @@ -0,0 +1,650 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * InteractionSseEventInteraction + * + *

Partial interaction resource emitted by interaction lifecycle SSE events. + * Streaming lifecycle payloads may omit fields that are only available on + * full non-streaming Interaction responses. + */ +@SuppressWarnings("all") +public class InteractionSseEventInteraction { + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + @JsonProperty("id") + private String id; + + /** + * Output only. The resource type. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("object") + private Optional object; + + /** + * The model that will complete your prompt. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("model") + private Optional model; + + /** + * The agent to interact with. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("agent") + private Optional agent; + + /** + * Required. Output only. The status of the interaction. + */ + @JsonProperty("status") + private InteractionSseEventInteractionStatus status; + + /** + * Output only. The time at which the response was created in ISO 8601 format. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("created") + private Optional created; + + /** + * Output only. The time at which the response was last updated in ISO 8601 format. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("updated") + private Optional updated; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("service_tier") + private Optional serviceTier; + + /** + * Statistics on the interaction request's token usage. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("usage") + private Optional usage; + + /** + * Output only. The steps that make up the interaction, if included in this event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("steps") + private Optional> steps; + + @JsonCreator + public InteractionSseEventInteraction( + @JsonProperty("id") String id, + @JsonProperty("object") Optional object, + @JsonProperty("model") Optional model, + @JsonProperty("agent") Optional agent, + @JsonProperty("status") InteractionSseEventInteractionStatus status, + @JsonProperty("created") Optional created, + @JsonProperty("updated") Optional updated, + @JsonProperty("service_tier") Optional serviceTier, + @JsonProperty("usage") Optional usage, + @JsonProperty("steps") Optional> steps) { + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(object, "object"); + Utils.checkNotNull(model, "model"); + Utils.checkNotNull(agent, "agent"); + Utils.checkNotNull(status, "status"); + Utils.checkNotNull(created, "created"); + Utils.checkNotNull(updated, "updated"); + Utils.checkNotNull(serviceTier, "serviceTier"); + Utils.checkNotNull(usage, "usage"); + Utils.checkNotNull(steps, "steps"); + this.id = id; + this.object = object; + this.model = model; + this.agent = agent; + this.status = status; + this.created = created; + this.updated = updated; + this.serviceTier = serviceTier; + this.usage = usage; + this.steps = steps; + } + + public InteractionSseEventInteraction( + String id, + InteractionSseEventInteractionStatus status) { + this(id, Optional.empty(), Optional.empty(), + Optional.empty(), status, Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * Output only. The resource type. + */ + @JsonIgnore + public Optional object() { + return object; + } + + /** + * The model that will complete your prompt. + */ + @JsonIgnore + public Optional model() { + return model; + } + + /** + * The agent to interact with. + */ + @JsonIgnore + public Optional agent() { + return agent; + } + + /** + * Required. Output only. The status of the interaction. + */ + @JsonIgnore + public InteractionSseEventInteractionStatus status() { + return status; + } + + /** + * Output only. The time at which the response was created in ISO 8601 format. + */ + @JsonIgnore + public Optional created() { + return created; + } + + /** + * Output only. The time at which the response was last updated in ISO 8601 format. + */ + @JsonIgnore + public Optional updated() { + return updated; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional serviceTier() { + return (Optional) serviceTier; + } + + /** + * Statistics on the interaction request's token usage. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional usage() { + return (Optional) usage; + } + + /** + * Output only. The steps that make up the interaction, if included in this event. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> steps() { + return (Optional>) steps; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + public InteractionSseEventInteraction withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * Output only. The resource type. + */ + public InteractionSseEventInteraction withObject(String object) { + Utils.checkNotNull(object, "object"); + this.object = Optional.ofNullable(object); + return this; + } + + + /** + * Output only. The resource type. + */ + public InteractionSseEventInteraction withObject(Optional object) { + Utils.checkNotNull(object, "object"); + this.object = object; + return this; + } + + /** + * The model that will complete your prompt. + */ + public InteractionSseEventInteraction withModel(String model) { + Utils.checkNotNull(model, "model"); + this.model = Optional.ofNullable(model); + return this; + } + + + /** + * The model that will complete your prompt. + */ + public InteractionSseEventInteraction withModel(Optional model) { + Utils.checkNotNull(model, "model"); + this.model = model; + return this; + } + + /** + * The agent to interact with. + */ + public InteractionSseEventInteraction withAgent(String agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + + /** + * The agent to interact with. + */ + public InteractionSseEventInteraction withAgent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + /** + * Required. Output only. The status of the interaction. + */ + public InteractionSseEventInteraction withStatus(InteractionSseEventInteractionStatus status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + /** + * Output only. The time at which the response was created in ISO 8601 format. + */ + public InteractionSseEventInteraction withCreated(String created) { + Utils.checkNotNull(created, "created"); + this.created = Optional.ofNullable(created); + return this; + } + + + /** + * Output only. The time at which the response was created in ISO 8601 format. + */ + public InteractionSseEventInteraction withCreated(Optional created) { + Utils.checkNotNull(created, "created"); + this.created = created; + return this; + } + + /** + * Output only. The time at which the response was last updated in ISO 8601 format. + */ + public InteractionSseEventInteraction withUpdated(String updated) { + Utils.checkNotNull(updated, "updated"); + this.updated = Optional.ofNullable(updated); + return this; + } + + + /** + * Output only. The time at which the response was last updated in ISO 8601 format. + */ + public InteractionSseEventInteraction withUpdated(Optional updated) { + Utils.checkNotNull(updated, "updated"); + this.updated = updated; + return this; + } + + public InteractionSseEventInteraction withServiceTier(ServiceTier serviceTier) { + Utils.checkNotNull(serviceTier, "serviceTier"); + this.serviceTier = Optional.ofNullable(serviceTier); + return this; + } + + + public InteractionSseEventInteraction withServiceTier(Optional serviceTier) { + Utils.checkNotNull(serviceTier, "serviceTier"); + this.serviceTier = serviceTier; + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public InteractionSseEventInteraction withUsage(Usage usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = Optional.ofNullable(usage); + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public InteractionSseEventInteraction withUsage(Optional usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = usage; + return this; + } + + /** + * Output only. The steps that make up the interaction, if included in this event. + */ + public InteractionSseEventInteraction withSteps(List steps) { + Utils.checkNotNull(steps, "steps"); + this.steps = Optional.ofNullable(steps); + return this; + } + + + /** + * Output only. The steps that make up the interaction, if included in this event. + */ + public InteractionSseEventInteraction withSteps(Optional> steps) { + Utils.checkNotNull(steps, "steps"); + this.steps = steps; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionSseEventInteraction other = (InteractionSseEventInteraction) o; + return + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.object, other.object) && + Utils.enhancedDeepEquals(this.model, other.model) && + Utils.enhancedDeepEquals(this.agent, other.agent) && + Utils.enhancedDeepEquals(this.status, other.status) && + Utils.enhancedDeepEquals(this.created, other.created) && + Utils.enhancedDeepEquals(this.updated, other.updated) && + Utils.enhancedDeepEquals(this.serviceTier, other.serviceTier) && + Utils.enhancedDeepEquals(this.usage, other.usage) && + Utils.enhancedDeepEquals(this.steps, other.steps); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + id, object, model, + agent, status, created, + updated, serviceTier, usage, + steps); + } + + @Override + public String toString() { + return Utils.toString(InteractionSseEventInteraction.class, + "id", id, + "object", object, + "model", model, + "agent", agent, + "status", status, + "created", created, + "updated", updated, + "serviceTier", serviceTier, + "usage", usage, + "steps", steps); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String id; + + private Optional object = Optional.empty(); + + private Optional model = Optional.empty(); + + private Optional agent = Optional.empty(); + + private InteractionSseEventInteractionStatus status; + + private Optional created = Optional.empty(); + + private Optional updated = Optional.empty(); + + private Optional serviceTier = Optional.empty(); + + private Optional usage = Optional.empty(); + + private Optional> steps = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. Output only. A unique identifier for the interaction completion. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * Output only. The resource type. + */ + public Builder object(String object) { + Utils.checkNotNull(object, "object"); + this.object = Optional.ofNullable(object); + return this; + } + + /** + * Output only. The resource type. + */ + public Builder object(Optional object) { + Utils.checkNotNull(object, "object"); + this.object = object; + return this; + } + + + /** + * The model that will complete your prompt. + */ + public Builder model(String model) { + Utils.checkNotNull(model, "model"); + this.model = Optional.ofNullable(model); + return this; + } + + /** + * The model that will complete your prompt. + */ + public Builder model(Optional model) { + Utils.checkNotNull(model, "model"); + this.model = model; + return this; + } + + + /** + * The agent to interact with. + */ + public Builder agent(String agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + /** + * The agent to interact with. + */ + public Builder agent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + + /** + * Required. Output only. The status of the interaction. + */ + public Builder status(InteractionSseEventInteractionStatus status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + + /** + * Output only. The time at which the response was created in ISO 8601 format. + */ + public Builder created(String created) { + Utils.checkNotNull(created, "created"); + this.created = Optional.ofNullable(created); + return this; + } + + /** + * Output only. The time at which the response was created in ISO 8601 format. + */ + public Builder created(Optional created) { + Utils.checkNotNull(created, "created"); + this.created = created; + return this; + } + + + /** + * Output only. The time at which the response was last updated in ISO 8601 format. + */ + public Builder updated(String updated) { + Utils.checkNotNull(updated, "updated"); + this.updated = Optional.ofNullable(updated); + return this; + } + + /** + * Output only. The time at which the response was last updated in ISO 8601 format. + */ + public Builder updated(Optional updated) { + Utils.checkNotNull(updated, "updated"); + this.updated = updated; + return this; + } + + + public Builder serviceTier(ServiceTier serviceTier) { + Utils.checkNotNull(serviceTier, "serviceTier"); + this.serviceTier = Optional.ofNullable(serviceTier); + return this; + } + + public Builder serviceTier(Optional serviceTier) { + Utils.checkNotNull(serviceTier, "serviceTier"); + this.serviceTier = serviceTier; + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public Builder usage(Usage usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = Optional.ofNullable(usage); + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Builder usage(Optional usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = usage; + return this; + } + + + /** + * Output only. The steps that make up the interaction, if included in this event. + */ + public Builder steps(List steps) { + Utils.checkNotNull(steps, "steps"); + this.steps = Optional.ofNullable(steps); + return this; + } + + /** + * Output only. The steps that make up the interaction, if included in this event. + */ + public Builder steps(Optional> steps) { + Utils.checkNotNull(steps, "steps"); + this.steps = steps; + return this; + } + + public InteractionSseEventInteraction build() { + + return new InteractionSseEventInteraction( + id, object, model, + agent, status, created, + updated, serviceTier, usage, + steps); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionSseEventInteractionStatus.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionSseEventInteractionStatus.java new file mode 100644 index 00000000000..edb202dd363 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionSseEventInteractionStatus.java @@ -0,0 +1,61 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * InteractionSseEventInteractionStatus + * + *

Required. Output only. The status of the interaction. + */ +@SuppressWarnings("all") +public enum InteractionSseEventInteractionStatus { + IN_PROGRESS("in_progress"), + REQUIRES_ACTION("requires_action"), + COMPLETED("completed"), + FAILED("failed"), + CANCELLED("cancelled"), + INCOMPLETE("incomplete"); + + @JsonValue + private final String value; + + InteractionSseEventInteractionStatus(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (InteractionSseEventInteractionStatus o: InteractionSseEventInteractionStatus.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatus.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatus.java new file mode 100644 index 00000000000..96a152d6e53 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatus.java @@ -0,0 +1,62 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * InteractionStatus + * + *

Required. Output only. The status of the interaction. + */ +@SuppressWarnings("all") +public enum InteractionStatus { + IN_PROGRESS("in_progress"), + REQUIRES_ACTION("requires_action"), + COMPLETED("completed"), + FAILED("failed"), + CANCELLED("cancelled"), + INCOMPLETE("incomplete"), + BUDGET_EXCEEDED("budget_exceeded"); + + @JsonValue + private final String value; + + InteractionStatus(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (InteractionStatus o: InteractionStatus.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatusUpdate.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatusUpdate.java new file mode 100644 index 00000000000..9c888733592 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatusUpdate.java @@ -0,0 +1,279 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class InteractionStatusUpdate { + + @JsonProperty("event_type") + private String eventType; + + + @JsonProperty("interaction_id") + private String interactionId; + + + @JsonProperty("status") + private InteractionStatusUpdateStatus status; + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("event_id") + private Optional eventId; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata") + private Optional metadata; + + @JsonCreator + public InteractionStatusUpdate( + @JsonProperty("interaction_id") String interactionId, + @JsonProperty("status") InteractionStatusUpdateStatus status, + @JsonProperty("event_id") Optional eventId, + @JsonProperty("metadata") Optional metadata) { + Utils.checkNotNull(interactionId, "interactionId"); + Utils.checkNotNull(status, "status"); + Utils.checkNotNull(eventId, "eventId"); + Utils.checkNotNull(metadata, "metadata"); + this.eventType = Builder._SINGLETON_VALUE_EventType.value(); + this.interactionId = interactionId; + this.status = status; + this.eventId = eventId; + this.metadata = metadata; + } + + public InteractionStatusUpdate( + String interactionId, + InteractionStatusUpdateStatus status) { + this(interactionId, status, Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String eventType() { + return eventType; + } + + @JsonIgnore + public String interactionId() { + return interactionId; + } + + @JsonIgnore + public InteractionStatusUpdateStatus status() { + return status; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonIgnore + public Optional eventId() { + return eventId; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional metadata() { + return (Optional) metadata; + } + + public static Builder builder() { + return new Builder(); + } + + + public InteractionStatusUpdate withInteractionId(String interactionId) { + Utils.checkNotNull(interactionId, "interactionId"); + this.interactionId = interactionId; + return this; + } + + public InteractionStatusUpdate withStatus(InteractionStatusUpdateStatus status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public InteractionStatusUpdate withEventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public InteractionStatusUpdate withEventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + public InteractionStatusUpdate withMetadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + + public InteractionStatusUpdate withMetadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionStatusUpdate other = (InteractionStatusUpdate) o; + return + Utils.enhancedDeepEquals(this.eventType, other.eventType) && + Utils.enhancedDeepEquals(this.interactionId, other.interactionId) && + Utils.enhancedDeepEquals(this.status, other.status) && + Utils.enhancedDeepEquals(this.eventId, other.eventId) && + Utils.enhancedDeepEquals(this.metadata, other.metadata); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + eventType, interactionId, status, + eventId, metadata); + } + + @Override + public String toString() { + return Utils.toString(InteractionStatusUpdate.class, + "eventType", eventType, + "interactionId", interactionId, + "status", status, + "eventId", eventId, + "metadata", metadata); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String interactionId; + + private InteractionStatusUpdateStatus status; + + private Optional eventId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder interactionId(String interactionId) { + Utils.checkNotNull(interactionId, "interactionId"); + this.interactionId = interactionId; + return this; + } + + + public Builder status(InteractionStatusUpdateStatus status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + + public Builder metadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public Builder metadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + public InteractionStatusUpdate build() { + + return new InteractionStatusUpdate( + interactionId, status, eventId, + metadata); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_EventType = + new LazySingletonValue<>( + "event_type", + "\"interaction.status_update\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatusUpdateStatus.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatusUpdateStatus.java new file mode 100644 index 00000000000..9adc5297e67 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionStatusUpdateStatus.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum InteractionStatusUpdateStatus { + IN_PROGRESS("in_progress"), + REQUIRES_ACTION("requires_action"), + COMPLETED("completed"), + FAILED("failed"), + CANCELLED("cancelled"), + INCOMPLETE("incomplete"), + BUDGET_EXCEEDED("budget_exceeded"); + + @JsonValue + private final String value; + + InteractionStatusUpdateStatus(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (InteractionStatusUpdateStatus o: InteractionStatusUpdateStatus.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + 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 new file mode 100644 index 00000000000..e9be2a5f57d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionsInput.java @@ -0,0 +1,138 @@ +/* +* 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.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.List; + +/** + * InteractionsInput + * + *

The input for the interaction. + */ +@JsonDeserialize(using = InteractionsInput._Deserializer.class) +@SuppressWarnings("all") +public class InteractionsInput { + + @JsonValue + private final TypedObject value; + + private InteractionsInput(TypedObject value) { + this.value = value; + } + + public static InteractionsInput of(String value) { + Utils.checkNotNull(value, "value"); + return new InteractionsInput(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionsInput ofStep(List value) { + Utils.checkNotNull(value, "value"); + return new InteractionsInput(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static InteractionsInput ofContent(List value) { + Utils.checkNotNull(value, "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<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code java.lang.String}
  • + *
  • {@code java.util.List}
  • + *
  • {@code java.util.List}
  • + *
  • {@code java.util.List}
  • + *
  • {@code com.google.genai.gaos.models.interactions.Content}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InteractionsInput other = (InteractionsInput) 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(InteractionsInput.class, false, + 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)); + } + } + + @Override + public String toString() { + return Utils.toString(InteractionsInput.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Language.java b/src/main/java/com/google/genai/gaos/models/interactions/Language.java new file mode 100644 index 00000000000..3228a15af88 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Language.java @@ -0,0 +1,56 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * Language + * + *

Programming language of the `code`. + */ +@SuppressWarnings("all") +public enum Language { + PYTHON("python"); + + @JsonValue + private final String value; + + Language(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (Language o: Language.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServer.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServer.java new file mode 100644 index 00000000000..fb2f82dd758 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServer.java @@ -0,0 +1,264 @@ +/* +* 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.Override; +import java.lang.String; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * MCPServer + * + *

A MCPServer is a server that can be called by the model to perform actions. + */ +@SuppressWarnings("all") +public class MCPServer { + + @JsonProperty("type") + private String type; + + /** + * The name of the MCPServer. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private String name; + + /** + * The full URL for the MCPServer endpoint. + * Example: "https://api.example.com/mcp" + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("url") + private String url; + + /** + * Optional: Fields for authentication headers, timeouts, etc., if needed. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("headers") + private Map headers; + + /** + * The allowed tools. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("allowed_tools") + private List allowedTools; + + @JsonCreator + public MCPServer( + @JsonProperty("name") @Nullable String name, + @JsonProperty("url") @Nullable String url, + @JsonProperty("headers") @Nullable Map headers, + @JsonProperty("allowed_tools") @Nullable List allowedTools) { + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.url = url; + this.headers = headers; + this.allowedTools = allowedTools; + } + + public MCPServer() { + this(null, null, null, + null); + } + + public String type() { + return Utils.discriminatorToString(type); + } + + /** + * The name of the MCPServer. + */ + public Optional name() { + return Optional.ofNullable(this.name); + } + + /** + * The full URL for the MCPServer endpoint. + * Example: "https://api.example.com/mcp" + */ + public Optional url() { + return Optional.ofNullable(this.url); + } + + /** + * Optional: Fields for authentication headers, timeouts, etc., if needed. + */ + public Optional> headers() { + return Optional.ofNullable(this.headers); + } + + /** + * The allowed tools. + */ + public Optional> allowedTools() { + return Optional.ofNullable(this.allowedTools); + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The name of the MCPServer. + */ + public MCPServer withName(@Nullable String name) { + this.name = name; + return this; + } + + + /** + * The full URL for the MCPServer endpoint. + * Example: "https://api.example.com/mcp" + */ + public MCPServer withUrl(@Nullable String url) { + this.url = url; + return this; + } + + + /** + * Optional: Fields for authentication headers, timeouts, etc., if needed. + */ + public MCPServer withHeaders(@Nullable Map headers) { + this.headers = headers; + return this; + } + + + /** + * The allowed tools. + */ + public MCPServer withAllowedTools(@Nullable List allowedTools) { + this.allowedTools = allowedTools; + return this; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MCPServer other = (MCPServer) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.url, other.url) && + Utils.enhancedDeepEquals(this.headers, other.headers) && + Utils.enhancedDeepEquals(this.allowedTools, other.allowedTools); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, url, + headers, allowedTools); + } + + @Override + public String toString() { + return Utils.toString(MCPServer.class, + "type", type, + "name", name, + "url", url, + "headers", headers, + "allowedTools", allowedTools); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String name; + + private String url; + + private Map headers; + + private List allowedTools; + + private Builder() { + // force use of static builder() method + } + + /** + * The name of the MCPServer. + */ + public Builder name(@Nullable String name) { + this.name = name; + return this; + } + + /** + * The full URL for the MCPServer endpoint. + * Example: "https://api.example.com/mcp" + */ + public Builder url(@Nullable String url) { + this.url = url; + return this; + } + + /** + * Optional: Fields for authentication headers, timeouts, etc., if needed. + */ + public Builder headers(@Nullable Map headers) { + this.headers = headers; + return this; + } + + /** + * The allowed tools. + */ + public Builder allowedTools(@Nullable List allowedTools) { + this.allowedTools = allowedTools; + return this; + } + + public MCPServer build() { + return new MCPServer( + name, url, headers, + allowedTools); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"mcp_server\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolCallDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolCallDelta.java new file mode 100644 index 00000000000..1fc3a5d1be1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolCallDelta.java @@ -0,0 +1,189 @@ +/* +* 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.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.util.Map; + + +@SuppressWarnings("all") +public class MCPServerToolCallDelta { + + @JsonProperty("type") + private String type; + + + @JsonProperty("name") + private String name; + + + @JsonProperty("server_name") + private String serverName; + + + @JsonProperty("arguments") + private Map arguments; + + @JsonCreator + public MCPServerToolCallDelta( + @JsonProperty("name") String name, + @JsonProperty("server_name") String serverName, + @JsonProperty("arguments") Map arguments) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(serverName, "serverName"); + arguments = Utils.emptyMapIfNull(arguments); + Utils.checkNotNull(arguments, "arguments"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.serverName = serverName; + this.arguments = arguments; + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public String name() { + return name; + } + + @JsonIgnore + public String serverName() { + return serverName; + } + + @JsonIgnore + public Map arguments() { + return arguments; + } + + public static Builder builder() { + return new Builder(); + } + + + public MCPServerToolCallDelta withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + public MCPServerToolCallDelta withServerName(String serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = serverName; + return this; + } + + public MCPServerToolCallDelta withArguments(Map arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MCPServerToolCallDelta other = (MCPServerToolCallDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.serverName, other.serverName) && + Utils.enhancedDeepEquals(this.arguments, other.arguments); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, serverName, + arguments); + } + + @Override + public String toString() { + return Utils.toString(MCPServerToolCallDelta.class, + "type", type, + "name", name, + "serverName", serverName, + "arguments", arguments); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String name; + + private String serverName; + + private Map arguments; + + private Builder() { + // force use of static builder() method + } + + + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + public Builder serverName(String serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = serverName; + return this; + } + + + public Builder arguments(Map arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + public MCPServerToolCallDelta build() { + + return new MCPServerToolCallDelta( + name, serverName, arguments); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"mcp_server_tool_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolCallStep.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolCallStep.java new file mode 100644 index 00000000000..f94cc05b371 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolCallStep.java @@ -0,0 +1,267 @@ +/* +* 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.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.util.Map; + +/** + * MCPServerToolCallStep + * + *

MCPServer tool call step. + */ +@SuppressWarnings("all") +public class MCPServerToolCallStep { + + @JsonProperty("type") + private String type; + + /** + * Required. The name of the tool which was called. + */ + @JsonProperty("name") + private String name; + + /** + * Required. The name of the used MCP server. + */ + @JsonProperty("server_name") + private String serverName; + + /** + * Required. The JSON object of arguments for the function. + */ + @JsonProperty("arguments") + private Map arguments; + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonProperty("id") + private String id; + + @JsonCreator + public MCPServerToolCallStep( + @JsonProperty("name") String name, + @JsonProperty("server_name") String serverName, + @JsonProperty("arguments") Map arguments, + @JsonProperty("id") String id) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(serverName, "serverName"); + arguments = Utils.emptyMapIfNull(arguments); + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(id, "id"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.serverName = serverName; + this.arguments = arguments; + this.id = id; + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. The name of the tool which was called. + */ + @JsonIgnore + public String name() { + return name; + } + + /** + * Required. The name of the used MCP server. + */ + @JsonIgnore + public String serverName() { + return serverName; + } + + /** + * Required. The JSON object of arguments for the function. + */ + @JsonIgnore + public Map arguments() { + return arguments; + } + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonIgnore + public String id() { + return id; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. The name of the tool which was called. + */ + public MCPServerToolCallStep withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * Required. The name of the used MCP server. + */ + public MCPServerToolCallStep withServerName(String serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = serverName; + return this; + } + + /** + * Required. The JSON object of arguments for the function. + */ + public MCPServerToolCallStep withArguments(Map arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * Required. A unique ID for this specific tool call. + */ + public MCPServerToolCallStep withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MCPServerToolCallStep other = (MCPServerToolCallStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.serverName, other.serverName) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.id, other.id); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, serverName, + arguments, id); + } + + @Override + public String toString() { + return Utils.toString(MCPServerToolCallStep.class, + "type", type, + "name", name, + "serverName", serverName, + "arguments", arguments, + "id", id); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String name; + + private String serverName; + + private Map arguments; + + private String id; + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. The name of the tool which was called. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * Required. The name of the used MCP server. + */ + public Builder serverName(String serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = serverName; + return this; + } + + + /** + * Required. The JSON object of arguments for the function. + */ + public Builder arguments(Map arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public MCPServerToolCallStep build() { + + return new MCPServerToolCallStep( + name, serverName, arguments, + id); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"mcp_server_tool_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDelta.java new file mode 100644 index 00000000000..309887b5979 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDelta.java @@ -0,0 +1,222 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class MCPServerToolResultDelta { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("server_name") + private Optional serverName; + + + @JsonProperty("result") + private MCPServerToolResultDeltaResultUnion result; + + @JsonCreator + public MCPServerToolResultDelta( + @JsonProperty("name") Optional name, + @JsonProperty("server_name") Optional serverName, + @JsonProperty("result") MCPServerToolResultDeltaResultUnion result) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(serverName, "serverName"); + Utils.checkNotNull(result, "result"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.serverName = serverName; + this.result = result; + } + + public MCPServerToolResultDelta( + MCPServerToolResultDeltaResultUnion result) { + this(Optional.empty(), Optional.empty(), result); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public Optional name() { + return name; + } + + @JsonIgnore + public Optional serverName() { + return serverName; + } + + @JsonIgnore + public MCPServerToolResultDeltaResultUnion result() { + return result; + } + + public static Builder builder() { + return new Builder(); + } + + + public MCPServerToolResultDelta withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + public MCPServerToolResultDelta withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + public MCPServerToolResultDelta withServerName(String serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = Optional.ofNullable(serverName); + return this; + } + + + public MCPServerToolResultDelta withServerName(Optional serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = serverName; + return this; + } + + public MCPServerToolResultDelta withResult(MCPServerToolResultDeltaResultUnion result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MCPServerToolResultDelta other = (MCPServerToolResultDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.serverName, other.serverName) && + Utils.enhancedDeepEquals(this.result, other.result); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, serverName, + result); + } + + @Override + public String toString() { + return Utils.toString(MCPServerToolResultDelta.class, + "type", type, + "name", name, + "serverName", serverName, + "result", result); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional name = Optional.empty(); + + private Optional serverName = Optional.empty(); + + private MCPServerToolResultDeltaResultUnion result; + + private Builder() { + // force use of static builder() method + } + + + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + public Builder serverName(String serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = Optional.ofNullable(serverName); + return this; + } + + public Builder serverName(Optional serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = serverName; + return this; + } + + + public Builder result(MCPServerToolResultDeltaResultUnion result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + public MCPServerToolResultDelta build() { + + return new MCPServerToolResultDelta( + name, serverName, result); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"mcp_server_tool_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDeltaResult.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDeltaResult.java new file mode 100644 index 00000000000..5dcfb2119de --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDeltaResult.java @@ -0,0 +1,75 @@ +/* +* 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.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + + +@SuppressWarnings("all") +public class MCPServerToolResultDeltaResult { + @JsonCreator + public MCPServerToolResultDeltaResult() { + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ); + } + + @Override + public String toString() { + return Utils.toString(MCPServerToolResultDeltaResult.class); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public MCPServerToolResultDeltaResult build() { + + return new MCPServerToolResultDeltaResult( + ); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDeltaResultUnion.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDeltaResultUnion.java new file mode 100644 index 00000000000..45b71db6dc8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultDeltaResultUnion.java @@ -0,0 +1,119 @@ +/* +* 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.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.List; + +@JsonDeserialize(using = MCPServerToolResultDeltaResultUnion._Deserializer.class) +@SuppressWarnings("all") +public class MCPServerToolResultDeltaResultUnion { + + @JsonValue + private final TypedObject value; + + private MCPServerToolResultDeltaResultUnion(TypedObject value) { + this.value = value; + } + + public static MCPServerToolResultDeltaResultUnion of(MCPServerToolResultDeltaResult value) { + Utils.checkNotNull(value, "value"); + return new MCPServerToolResultDeltaResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static MCPServerToolResultDeltaResultUnion of(List value) { + Utils.checkNotNull(value, "value"); + return new MCPServerToolResultDeltaResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static MCPServerToolResultDeltaResultUnion of(String value) { + Utils.checkNotNull(value, "value"); + return new MCPServerToolResultDeltaResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.MCPServerToolResultDeltaResult}
  • + *
  • {@code java.util.List}
  • + *
  • {@code java.lang.String}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MCPServerToolResultDeltaResultUnion other = (MCPServerToolResultDeltaResultUnion) 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(MCPServerToolResultDeltaResultUnion.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(MCPServerToolResultDeltaResultUnion.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStep.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStep.java new file mode 100644 index 00000000000..04555570d83 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStep.java @@ -0,0 +1,314 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * MCPServerToolResultStep + * + *

MCPServer tool result step. + */ +@SuppressWarnings("all") +public class MCPServerToolResultStep { + + @JsonProperty("type") + private String type; + + /** + * Name of the tool which is called for this specific tool call. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + /** + * The name of the used MCP server. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("server_name") + private Optional serverName; + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonProperty("call_id") + private String callId; + + /** + * The output from the MCP server call. Can be simple text or rich content. + */ + @JsonProperty("result") + private MCPServerToolResultStepResultUnion result; + + @JsonCreator + public MCPServerToolResultStep( + @JsonProperty("name") Optional name, + @JsonProperty("server_name") Optional serverName, + @JsonProperty("call_id") String callId, + @JsonProperty("result") MCPServerToolResultStepResultUnion result) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(serverName, "serverName"); + Utils.checkNotNull(callId, "callId"); + Utils.checkNotNull(result, "result"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.name = name; + this.serverName = serverName; + this.callId = callId; + this.result = result; + } + + public MCPServerToolResultStep( + String callId, + MCPServerToolResultStepResultUnion result) { + this(Optional.empty(), Optional.empty(), callId, + result); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Name of the tool which is called for this specific tool call. + */ + @JsonIgnore + public Optional name() { + return name; + } + + /** + * The name of the used MCP server. + */ + @JsonIgnore + public Optional serverName() { + return serverName; + } + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonIgnore + public String callId() { + return callId; + } + + /** + * The output from the MCP server call. Can be simple text or rich content. + */ + @JsonIgnore + public MCPServerToolResultStepResultUnion result() { + return result; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Name of the tool which is called for this specific tool call. + */ + public MCPServerToolResultStep withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + /** + * Name of the tool which is called for this specific tool call. + */ + public MCPServerToolResultStep withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * The name of the used MCP server. + */ + public MCPServerToolResultStep withServerName(String serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = Optional.ofNullable(serverName); + return this; + } + + + /** + * The name of the used MCP server. + */ + public MCPServerToolResultStep withServerName(Optional serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = serverName; + return this; + } + + /** + * Required. ID to match the ID from the function call block. + */ + public MCPServerToolResultStep withCallId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + /** + * The output from the MCP server call. Can be simple text or rich content. + */ + public MCPServerToolResultStep withResult(MCPServerToolResultStepResultUnion result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MCPServerToolResultStep other = (MCPServerToolResultStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.serverName, other.serverName) && + Utils.enhancedDeepEquals(this.callId, other.callId) && + Utils.enhancedDeepEquals(this.result, other.result); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, name, serverName, + callId, result); + } + + @Override + public String toString() { + return Utils.toString(MCPServerToolResultStep.class, + "type", type, + "name", name, + "serverName", serverName, + "callId", callId, + "result", result); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional name = Optional.empty(); + + private Optional serverName = Optional.empty(); + + private String callId; + + private MCPServerToolResultStepResultUnion result; + + private Builder() { + // force use of static builder() method + } + + + /** + * Name of the tool which is called for this specific tool call. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + /** + * Name of the tool which is called for this specific tool call. + */ + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * The name of the used MCP server. + */ + public Builder serverName(String serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = Optional.ofNullable(serverName); + return this; + } + + /** + * The name of the used MCP server. + */ + public Builder serverName(Optional serverName) { + Utils.checkNotNull(serverName, "serverName"); + this.serverName = serverName; + return this; + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public Builder callId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + + /** + * The output from the MCP server call. Can be simple text or rich content. + */ + public Builder result(MCPServerToolResultStepResultUnion result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + public MCPServerToolResultStep build() { + + return new MCPServerToolResultStep( + name, serverName, callId, + result); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"mcp_server_tool_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStepResult.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStepResult.java new file mode 100644 index 00000000000..73c4df9f648 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStepResult.java @@ -0,0 +1,75 @@ +/* +* 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.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + + +@SuppressWarnings("all") +public class MCPServerToolResultStepResult { + @JsonCreator + public MCPServerToolResultStepResult() { + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ); + } + + @Override + public String toString() { + return Utils.toString(MCPServerToolResultStepResult.class); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public MCPServerToolResultStepResult build() { + + return new MCPServerToolResultStepResult( + ); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStepResultUnion.java b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStepResultUnion.java new file mode 100644 index 00000000000..f29ce32a566 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MCPServerToolResultStepResultUnion.java @@ -0,0 +1,124 @@ +/* +* 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.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.List; + +/** + * MCPServerToolResultStepResultUnion + * + *

The output from the MCP server call. Can be simple text or rich content. + */ +@JsonDeserialize(using = MCPServerToolResultStepResultUnion._Deserializer.class) +@SuppressWarnings("all") +public class MCPServerToolResultStepResultUnion { + + @JsonValue + private final TypedObject value; + + private MCPServerToolResultStepResultUnion(TypedObject value) { + this.value = value; + } + + public static MCPServerToolResultStepResultUnion of(MCPServerToolResultStepResult value) { + Utils.checkNotNull(value, "value"); + return new MCPServerToolResultStepResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static MCPServerToolResultStepResultUnion of(String value) { + Utils.checkNotNull(value, "value"); + return new MCPServerToolResultStepResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static MCPServerToolResultStepResultUnion of(List value) { + Utils.checkNotNull(value, "value"); + return new MCPServerToolResultStepResultUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.MCPServerToolResultStepResult}
  • + *
  • {@code java.lang.String}
  • + *
  • {@code java.util.List}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MCPServerToolResultStepResultUnion other = (MCPServerToolResultStepResultUnion) 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(MCPServerToolResultStepResultUnion.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(MCPServerToolResultStepResultUnion.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MediaResolution.java b/src/main/java/com/google/genai/gaos/models/interactions/MediaResolution.java new file mode 100644 index 00000000000..85dd161be42 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MediaResolution.java @@ -0,0 +1,54 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum MediaResolution { + LOW("low"), + MEDIUM("medium"), + HIGH("high"), + ULTRA_HIGH("ultra_high"); + + @JsonValue + private final String value; + + MediaResolution(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (MediaResolution o: MediaResolution.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ModalityTokens.java b/src/main/java/com/google/genai/gaos/models/interactions/ModalityTokens.java new file mode 100644 index 00000000000..8c52f62a09a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ModalityTokens.java @@ -0,0 +1,195 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * ModalityTokens + * + *

The token count for a single response modality. + */ +@SuppressWarnings("all") +public class ModalityTokens { + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("modality") + private Optional modality; + + /** + * Number of tokens for the modality. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("tokens") + private Optional tokens; + + @JsonCreator + public ModalityTokens( + @JsonProperty("modality") Optional modality, + @JsonProperty("tokens") Optional tokens) { + Utils.checkNotNull(modality, "modality"); + Utils.checkNotNull(tokens, "tokens"); + this.modality = modality; + this.tokens = tokens; + } + + public ModalityTokens() { + this(Optional.empty(), Optional.empty()); + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional modality() { + return (Optional) modality; + } + + /** + * Number of tokens for the modality. + */ + @JsonIgnore + public Optional tokens() { + return tokens; + } + + public static Builder builder() { + return new Builder(); + } + + + public ModalityTokens withModality(ResponseModality modality) { + Utils.checkNotNull(modality, "modality"); + this.modality = Optional.ofNullable(modality); + return this; + } + + + public ModalityTokens withModality(Optional modality) { + Utils.checkNotNull(modality, "modality"); + this.modality = modality; + return this; + } + + /** + * Number of tokens for the modality. + */ + public ModalityTokens withTokens(int tokens) { + Utils.checkNotNull(tokens, "tokens"); + this.tokens = Optional.ofNullable(tokens); + return this; + } + + + /** + * Number of tokens for the modality. + */ + public ModalityTokens withTokens(Optional tokens) { + Utils.checkNotNull(tokens, "tokens"); + this.tokens = tokens; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModalityTokens other = (ModalityTokens) o; + return + Utils.enhancedDeepEquals(this.modality, other.modality) && + Utils.enhancedDeepEquals(this.tokens, other.tokens); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + modality, tokens); + } + + @Override + public String toString() { + return Utils.toString(ModalityTokens.class, + "modality", modality, + "tokens", tokens); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional modality = Optional.empty(); + + private Optional tokens = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder modality(ResponseModality modality) { + Utils.checkNotNull(modality, "modality"); + this.modality = Optional.ofNullable(modality); + return this; + } + + public Builder modality(Optional modality) { + Utils.checkNotNull(modality, "modality"); + this.modality = modality; + return this; + } + + + /** + * Number of tokens for the modality. + */ + public Builder tokens(int tokens) { + Utils.checkNotNull(tokens, "tokens"); + this.tokens = Optional.ofNullable(tokens); + return this; + } + + /** + * Number of tokens for the modality. + */ + public Builder tokens(Optional tokens) { + Utils.checkNotNull(tokens, "tokens"); + this.tokens = tokens; + return this; + } + + public ModalityTokens build() { + + return new ModalityTokens( + modality, tokens); + } + + } +} 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 new file mode 100644 index 00000000000..aae1ed1be57 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Model.java @@ -0,0 +1,226 @@ +/* +* 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. + */ +/** + * Model + * + *

The model that will complete your prompt.\n\nSee + * [models](https://ai.google.dev/gemini-api/docs/models) for additional details. + */ +@SuppressWarnings("all") +public class Model { + + public static final Model GEMINI25_COMPUTER_USE_PREVIEW102025 = new Model("gemini-2.5-computer-use-preview-10-2025"); + public static final Model GEMINI25_FLASH = new Model("gemini-2.5-flash"); + public static final Model GEMINI25_FLASH_IMAGE = new Model("gemini-2.5-flash-image"); + public static final Model GEMINI25_FLASH_LITE = new Model("gemini-2.5-flash-lite"); + public static final Model GEMINI25_FLASH_LITE_PREVIEW092025 = new Model("gemini-2.5-flash-lite-preview-09-2025"); + public static final Model GEMINI25_FLASH_NATIVE_AUDIO_PREVIEW122025 = new Model("gemini-2.5-flash-native-audio-preview-12-2025"); + public static final Model GEMINI25_FLASH_PREVIEW092025 = new Model("gemini-2.5-flash-preview-09-2025"); + public static final Model GEMINI25_FLASH_PREVIEW_TTS = new Model("gemini-2.5-flash-preview-tts"); + public static final Model GEMINI25_PRO = new Model("gemini-2.5-pro"); + public static final Model GEMINI25_PRO_PREVIEW_TTS = new Model("gemini-2.5-pro-preview-tts"); + public static final Model GEMINI3_FLASH_PREVIEW = new Model("gemini-3-flash-preview"); + public static final Model GEMINI3_PRO_IMAGE_PREVIEW = new Model("gemini-3-pro-image-preview"); + public static final Model GEMINI3_PRO_PREVIEW = new Model("gemini-3-pro-preview"); + public static final Model GEMINI31_PRO_PREVIEW = new Model("gemini-3.1-pro-preview"); + public static final Model GEMINI31_FLASH_IMAGE_PREVIEW = new Model("gemini-3.1-flash-image-preview"); + public static final Model GEMINI31_FLASH_LITE = new Model("gemini-3.1-flash-lite"); + public static final Model GEMINI31_FLASH_LITE_PREVIEW = new Model("gemini-3.1-flash-lite-preview"); + public static final Model GEMINI31_FLASH_TTS_PREVIEW = new Model("gemini-3.1-flash-tts-preview"); + public static final Model GEMINI35_FLASH = new Model("gemini-3.5-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"); + + // 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 Model(String value) { + this.value = value; + } + + /** + * Returns a Model 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 Model + */ + @JsonCreator + public static Model of(String value) { + synchronized (Model.class) { + return values.computeIfAbsent(value, v -> new Model(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; + Model other = (Model) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "Model [value=" + value + "]"; + } + + // return an array just like an enum + public static Model[] values() { + synchronized (Model.class) { + return values.values().toArray(new Model[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("gemini-2.5-computer-use-preview-10-2025", GEMINI25_COMPUTER_USE_PREVIEW102025); + map.put("gemini-2.5-flash", GEMINI25_FLASH); + map.put("gemini-2.5-flash-image", GEMINI25_FLASH_IMAGE); + map.put("gemini-2.5-flash-lite", GEMINI25_FLASH_LITE); + map.put("gemini-2.5-flash-lite-preview-09-2025", GEMINI25_FLASH_LITE_PREVIEW092025); + map.put("gemini-2.5-flash-native-audio-preview-12-2025", GEMINI25_FLASH_NATIVE_AUDIO_PREVIEW122025); + map.put("gemini-2.5-flash-preview-09-2025", GEMINI25_FLASH_PREVIEW092025); + map.put("gemini-2.5-flash-preview-tts", GEMINI25_FLASH_PREVIEW_TTS); + map.put("gemini-2.5-pro", GEMINI25_PRO); + map.put("gemini-2.5-pro-preview-tts", GEMINI25_PRO_PREVIEW_TTS); + map.put("gemini-3-flash-preview", GEMINI3_FLASH_PREVIEW); + map.put("gemini-3-pro-image-preview", GEMINI3_PRO_IMAGE_PREVIEW); + map.put("gemini-3-pro-preview", GEMINI3_PRO_PREVIEW); + map.put("gemini-3.1-pro-preview", GEMINI31_PRO_PREVIEW); + map.put("gemini-3.1-flash-image-preview", GEMINI31_FLASH_IMAGE_PREVIEW); + map.put("gemini-3.1-flash-lite", GEMINI31_FLASH_LITE); + map.put("gemini-3.1-flash-lite-preview", GEMINI31_FLASH_LITE_PREVIEW); + map.put("gemini-3.1-flash-tts-preview", GEMINI31_FLASH_TTS_PREVIEW); + map.put("gemini-3.5-flash", GEMINI35_FLASH); + map.put("lyria-3-clip-preview", LYRIA3_CLIP_PREVIEW); + map.put("lyria-3-pro-preview", LYRIA3_PRO_PREVIEW); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("gemini-2.5-computer-use-preview-10-2025", ModelEnum.GEMINI25_COMPUTER_USE_PREVIEW102025); + map.put("gemini-2.5-flash", ModelEnum.GEMINI25_FLASH); + map.put("gemini-2.5-flash-image", ModelEnum.GEMINI25_FLASH_IMAGE); + map.put("gemini-2.5-flash-lite", ModelEnum.GEMINI25_FLASH_LITE); + map.put("gemini-2.5-flash-lite-preview-09-2025", ModelEnum.GEMINI25_FLASH_LITE_PREVIEW092025); + map.put("gemini-2.5-flash-native-audio-preview-12-2025", ModelEnum.GEMINI25_FLASH_NATIVE_AUDIO_PREVIEW122025); + map.put("gemini-2.5-flash-preview-09-2025", ModelEnum.GEMINI25_FLASH_PREVIEW092025); + map.put("gemini-2.5-flash-preview-tts", ModelEnum.GEMINI25_FLASH_PREVIEW_TTS); + map.put("gemini-2.5-pro", ModelEnum.GEMINI25_PRO); + map.put("gemini-2.5-pro-preview-tts", ModelEnum.GEMINI25_PRO_PREVIEW_TTS); + map.put("gemini-3-flash-preview", ModelEnum.GEMINI3_FLASH_PREVIEW); + map.put("gemini-3-pro-image-preview", ModelEnum.GEMINI3_PRO_IMAGE_PREVIEW); + map.put("gemini-3-pro-preview", ModelEnum.GEMINI3_PRO_PREVIEW); + map.put("gemini-3.1-pro-preview", ModelEnum.GEMINI31_PRO_PREVIEW); + map.put("gemini-3.1-flash-image-preview", ModelEnum.GEMINI31_FLASH_IMAGE_PREVIEW); + map.put("gemini-3.1-flash-lite", ModelEnum.GEMINI31_FLASH_LITE); + map.put("gemini-3.1-flash-lite-preview", ModelEnum.GEMINI31_FLASH_LITE_PREVIEW); + map.put("gemini-3.1-flash-tts-preview", ModelEnum.GEMINI31_FLASH_TTS_PREVIEW); + map.put("gemini-3.5-flash", ModelEnum.GEMINI35_FLASH); + map.put("lyria-3-clip-preview", ModelEnum.LYRIA3_CLIP_PREVIEW); + map.put("lyria-3-pro-preview", ModelEnum.LYRIA3_PRO_PREVIEW); + return map; + } + + + public enum ModelEnum { + + GEMINI25_COMPUTER_USE_PREVIEW102025("gemini-2.5-computer-use-preview-10-2025"), + GEMINI25_FLASH("gemini-2.5-flash"), + GEMINI25_FLASH_IMAGE("gemini-2.5-flash-image"), + GEMINI25_FLASH_LITE("gemini-2.5-flash-lite"), + GEMINI25_FLASH_LITE_PREVIEW092025("gemini-2.5-flash-lite-preview-09-2025"), + GEMINI25_FLASH_NATIVE_AUDIO_PREVIEW122025("gemini-2.5-flash-native-audio-preview-12-2025"), + GEMINI25_FLASH_PREVIEW092025("gemini-2.5-flash-preview-09-2025"), + GEMINI25_FLASH_PREVIEW_TTS("gemini-2.5-flash-preview-tts"), + GEMINI25_PRO("gemini-2.5-pro"), + GEMINI25_PRO_PREVIEW_TTS("gemini-2.5-pro-preview-tts"), + GEMINI3_FLASH_PREVIEW("gemini-3-flash-preview"), + GEMINI3_PRO_IMAGE_PREVIEW("gemini-3-pro-image-preview"), + GEMINI3_PRO_PREVIEW("gemini-3-pro-preview"), + GEMINI31_PRO_PREVIEW("gemini-3.1-pro-preview"), + GEMINI31_FLASH_IMAGE_PREVIEW("gemini-3.1-flash-image-preview"), + GEMINI31_FLASH_LITE("gemini-3.1-flash-lite"), + GEMINI31_FLASH_LITE_PREVIEW("gemini-3.1-flash-lite-preview"), + GEMINI31_FLASH_TTS_PREVIEW("gemini-3.1-flash-tts-preview"), + GEMINI35_FLASH("gemini-3.5-flash"), + LYRIA3_CLIP_PREVIEW("lyria-3-clip-preview"), + LYRIA3_PRO_PREVIEW("lyria-3-pro-preview"),; + + private final String value; + + private ModelEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ModelOutputStep.java b/src/main/java/com/google/genai/gaos/models/interactions/ModelOutputStep.java new file mode 100644 index 00000000000..96c39fce9a3 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ModelOutputStep.java @@ -0,0 +1,252 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * ModelOutputStep + * + *

Output generated by the model. + */ +@SuppressWarnings("all") +public class ModelOutputStep { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("content") + private Optional> content; + + /** + * The `Status` type defines a logical error model that is suitable for + * different programming environments, including REST APIs and RPC APIs. It is + * used by [gRPC](https://github.com/grpc). Each `Status` message contains + * three pieces of data: error code, error message, and error details. + * + *

You can find out more about this error model and how to work with it in the + * [API Design Guide](https://cloud.google.com/apis/design/errors). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("error") + private Optional error; + + @JsonCreator + public ModelOutputStep( + @JsonProperty("content") Optional> content, + @JsonProperty("error") Optional error) { + Utils.checkNotNull(content, "content"); + Utils.checkNotNull(error, "error"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.content = content; + this.error = error; + } + + public ModelOutputStep() { + this(Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> content() { + return (Optional>) content; + } + + /** + * The `Status` type defines a logical error model that is suitable for + * different programming environments, including REST APIs and RPC APIs. It is + * used by [gRPC](https://github.com/grpc). Each `Status` message contains + * three pieces of data: error code, error message, and error details. + * + *

You can find out more about this error model and how to work with it in the + * [API Design Guide](https://cloud.google.com/apis/design/errors). + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional error() { + return (Optional) error; + } + + public static Builder builder() { + return new Builder(); + } + + + public ModelOutputStep withContent(List content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + + public ModelOutputStep withContent(Optional> content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + /** + * The `Status` type defines a logical error model that is suitable for + * different programming environments, including REST APIs and RPC APIs. It is + * used by [gRPC](https://github.com/grpc). Each `Status` message contains + * three pieces of data: error code, error message, and error details. + * + *

You can find out more about this error model and how to work with it in the + * [API Design Guide](https://cloud.google.com/apis/design/errors). + */ + public ModelOutputStep withError(Status error) { + Utils.checkNotNull(error, "error"); + this.error = Optional.ofNullable(error); + return this; + } + + + /** + * The `Status` type defines a logical error model that is suitable for + * different programming environments, including REST APIs and RPC APIs. It is + * used by [gRPC](https://github.com/grpc). Each `Status` message contains + * three pieces of data: error code, error message, and error details. + * + *

You can find out more about this error model and how to work with it in the + * [API Design Guide](https://cloud.google.com/apis/design/errors). + */ + public ModelOutputStep withError(Optional error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelOutputStep other = (ModelOutputStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.content, other.content) && + Utils.enhancedDeepEquals(this.error, other.error); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, content, error); + } + + @Override + public String toString() { + return Utils.toString(ModelOutputStep.class, + "type", type, + "content", content, + "error", error); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> content = Optional.empty(); + + private Optional error = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder content(List content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + public Builder content(Optional> content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + + /** + * The `Status` type defines a logical error model that is suitable for + * different programming environments, including REST APIs and RPC APIs. It is + * used by [gRPC](https://github.com/grpc). Each `Status` message contains + * three pieces of data: error code, error message, and error details. + * + *

You can find out more about this error model and how to work with it in the + * [API Design Guide](https://cloud.google.com/apis/design/errors). + */ + public Builder error(Status error) { + Utils.checkNotNull(error, "error"); + this.error = Optional.ofNullable(error); + return this; + } + + /** + * The `Status` type defines a logical error model that is suitable for + * different programming environments, including REST APIs and RPC APIs. It is + * used by [gRPC](https://github.com/grpc). Each `Status` message contains + * three pieces of data: error code, error message, and error details. + * + *

You can find out more about this error model and how to work with it in the + * [API Design Guide](https://cloud.google.com/apis/design/errors). + */ + public Builder error(Optional error) { + Utils.checkNotNull(error, "error"); + this.error = error; + return this; + } + + public ModelOutputStep build() { + + return new ModelOutputStep( + content, error); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"model_output\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Network.java b/src/main/java/com/google/genai/gaos/models/interactions/Network.java new file mode 100644 index 00000000000..310a8854aec --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Network.java @@ -0,0 +1,116 @@ +/* +* 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.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; + +/** + * Network + * + *

Network configuration for the environment. + */ +@JsonDeserialize(using = Network._Deserializer.class) +@SuppressWarnings("all") +public class Network { + + @JsonValue + private final TypedObject value; + + private Network(TypedObject value) { + this.value = value; + } + + public static Network of(EnvironmentNetworkEgressAllowlist value) { + Utils.checkNotNull(value, "value"); + return new Network(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Network of(NetworkEnum value) { + Utils.checkNotNull(value, "value"); + return new Network(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.EnvironmentNetworkEgressAllowlist}
  • + *
  • {@code com.google.genai.gaos.models.interactions.NetworkEnum}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Network other = (Network) 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(Network.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(Network.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/NetworkEnum.java b/src/main/java/com/google/genai/gaos/models/interactions/NetworkEnum.java new file mode 100644 index 00000000000..476159ae204 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/NetworkEnum.java @@ -0,0 +1,51 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum NetworkEnum { + DISABLED("disabled"); + + @JsonValue + private final String value; + + NetworkEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (NetworkEnum o: NetworkEnum.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ParallelAISearchConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/ParallelAISearchConfig.java new file mode 100644 index 00000000000..f15e3a1c8dd --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ParallelAISearchConfig.java @@ -0,0 +1,213 @@ +/* +* 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.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Map; +import java.util.Optional; + +/** + * ParallelAISearchConfig + * + *

Used to specify configuration for ParallelAISearch. + */ +@SuppressWarnings("all") +public class ParallelAISearchConfig { + /** + * Optional. The API key for ParallelAiSearch. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("api_key") + private Optional apiKey; + + /** + * Optional. Custom configs for ParallelAiSearch. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("custom_config") + private Optional> customConfig; + + @JsonCreator + public ParallelAISearchConfig( + @JsonProperty("api_key") Optional apiKey, + @JsonProperty("custom_config") Optional> customConfig) { + Utils.checkNotNull(apiKey, "apiKey"); + Utils.checkNotNull(customConfig, "customConfig"); + this.apiKey = apiKey; + this.customConfig = customConfig; + } + + public ParallelAISearchConfig() { + this(Optional.empty(), Optional.empty()); + } + + /** + * Optional. The API key for ParallelAiSearch. + */ + @JsonIgnore + public Optional apiKey() { + return apiKey; + } + + /** + * Optional. Custom configs for ParallelAiSearch. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> customConfig() { + return (Optional>) customConfig; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. The API key for ParallelAiSearch. + */ + public ParallelAISearchConfig withApiKey(String apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = Optional.ofNullable(apiKey); + return this; + } + + + /** + * Optional. The API key for ParallelAiSearch. + */ + public ParallelAISearchConfig withApiKey(Optional apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = apiKey; + return this; + } + + /** + * Optional. Custom configs for ParallelAiSearch. + */ + public ParallelAISearchConfig withCustomConfig(Map customConfig) { + Utils.checkNotNull(customConfig, "customConfig"); + this.customConfig = Optional.ofNullable(customConfig); + return this; + } + + + /** + * Optional. Custom configs for ParallelAiSearch. + */ + public ParallelAISearchConfig withCustomConfig(Optional> customConfig) { + Utils.checkNotNull(customConfig, "customConfig"); + this.customConfig = customConfig; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParallelAISearchConfig other = (ParallelAISearchConfig) o; + return + Utils.enhancedDeepEquals(this.apiKey, other.apiKey) && + Utils.enhancedDeepEquals(this.customConfig, other.customConfig); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiKey, customConfig); + } + + @Override + public String toString() { + return Utils.toString(ParallelAISearchConfig.class, + "apiKey", apiKey, + "customConfig", customConfig); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiKey = Optional.empty(); + + private Optional> customConfig = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. The API key for ParallelAiSearch. + */ + public Builder apiKey(String apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = Optional.ofNullable(apiKey); + return this; + } + + /** + * Optional. The API key for ParallelAiSearch. + */ + public Builder apiKey(Optional apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = apiKey; + return this; + } + + + /** + * Optional. Custom configs for ParallelAiSearch. + */ + public Builder customConfig(Map customConfig) { + Utils.checkNotNull(customConfig, "customConfig"); + this.customConfig = Optional.ofNullable(customConfig); + return this; + } + + /** + * Optional. Custom configs for ParallelAiSearch. + */ + public Builder customConfig(Optional> customConfig) { + Utils.checkNotNull(customConfig, "customConfig"); + this.customConfig = customConfig; + return this; + } + + public ParallelAISearchConfig build() { + + return new ParallelAISearchConfig( + apiKey, customConfig); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/PlaceCitation.java b/src/main/java/com/google/genai/gaos/models/interactions/PlaceCitation.java new file mode 100644 index 00000000000..81a74659f85 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/PlaceCitation.java @@ -0,0 +1,495 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * PlaceCitation + * + *

A place citation annotation. + */ +@SuppressWarnings("all") +public class PlaceCitation { + + @JsonProperty("type") + private String type; + + /** + * The ID of the place, in `places/{place_id}` format. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("place_id") + private Optional placeId; + + /** + * Title of the place. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + /** + * URI reference of the place. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("url") + private Optional url; + + /** + * Snippets of reviews that are used to generate answers about the + * features of a given place in Google Maps. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("review_snippets") + private Optional> reviewSnippets; + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("start_index") + private Optional startIndex; + + /** + * End of the attributed segment, exclusive. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("end_index") + private Optional endIndex; + + @JsonCreator + public PlaceCitation( + @JsonProperty("place_id") Optional placeId, + @JsonProperty("name") Optional name, + @JsonProperty("url") Optional url, + @JsonProperty("review_snippets") Optional> reviewSnippets, + @JsonProperty("start_index") Optional startIndex, + @JsonProperty("end_index") Optional endIndex) { + Utils.checkNotNull(placeId, "placeId"); + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(url, "url"); + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + Utils.checkNotNull(startIndex, "startIndex"); + Utils.checkNotNull(endIndex, "endIndex"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.placeId = placeId; + this.name = name; + this.url = url; + this.reviewSnippets = reviewSnippets; + this.startIndex = startIndex; + this.endIndex = endIndex; + } + + public PlaceCitation() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The ID of the place, in `places/{place_id}` format. + */ + @JsonIgnore + public Optional placeId() { + return placeId; + } + + /** + * Title of the place. + */ + @JsonIgnore + public Optional name() { + return name; + } + + /** + * URI reference of the place. + */ + @JsonIgnore + public Optional url() { + return url; + } + + /** + * Snippets of reviews that are used to generate answers about the + * features of a given place in Google Maps. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> reviewSnippets() { + return (Optional>) reviewSnippets; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + @JsonIgnore + public Optional startIndex() { + return startIndex; + } + + /** + * End of the attributed segment, exclusive. + */ + @JsonIgnore + public Optional endIndex() { + return endIndex; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The ID of the place, in `places/{place_id}` format. + */ + public PlaceCitation withPlaceId(String placeId) { + Utils.checkNotNull(placeId, "placeId"); + this.placeId = Optional.ofNullable(placeId); + return this; + } + + + /** + * The ID of the place, in `places/{place_id}` format. + */ + public PlaceCitation withPlaceId(Optional placeId) { + Utils.checkNotNull(placeId, "placeId"); + this.placeId = placeId; + return this; + } + + /** + * Title of the place. + */ + public PlaceCitation withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + /** + * Title of the place. + */ + public PlaceCitation withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * URI reference of the place. + */ + public PlaceCitation withUrl(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + + /** + * URI reference of the place. + */ + public PlaceCitation withUrl(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + /** + * Snippets of reviews that are used to generate answers about the + * features of a given place in Google Maps. + */ + public PlaceCitation withReviewSnippets(List reviewSnippets) { + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.reviewSnippets = Optional.ofNullable(reviewSnippets); + return this; + } + + + /** + * Snippets of reviews that are used to generate answers about the + * features of a given place in Google Maps. + */ + public PlaceCitation withReviewSnippets(Optional> reviewSnippets) { + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.reviewSnippets = reviewSnippets; + return this; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public PlaceCitation withStartIndex(int startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = Optional.ofNullable(startIndex); + return this; + } + + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public PlaceCitation withStartIndex(Optional startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = startIndex; + return this; + } + + /** + * End of the attributed segment, exclusive. + */ + public PlaceCitation withEndIndex(int endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = Optional.ofNullable(endIndex); + return this; + } + + + /** + * End of the attributed segment, exclusive. + */ + public PlaceCitation withEndIndex(Optional endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = endIndex; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlaceCitation other = (PlaceCitation) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.placeId, other.placeId) && + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.url, other.url) && + Utils.enhancedDeepEquals(this.reviewSnippets, other.reviewSnippets) && + Utils.enhancedDeepEquals(this.startIndex, other.startIndex) && + Utils.enhancedDeepEquals(this.endIndex, other.endIndex); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, placeId, name, + url, reviewSnippets, startIndex, + endIndex); + } + + @Override + public String toString() { + return Utils.toString(PlaceCitation.class, + "type", type, + "placeId", placeId, + "name", name, + "url", url, + "reviewSnippets", reviewSnippets, + "startIndex", startIndex, + "endIndex", endIndex); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional placeId = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional> reviewSnippets = Optional.empty(); + + private Optional startIndex = Optional.empty(); + + private Optional endIndex = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The ID of the place, in `places/{place_id}` format. + */ + public Builder placeId(String placeId) { + Utils.checkNotNull(placeId, "placeId"); + this.placeId = Optional.ofNullable(placeId); + return this; + } + + /** + * The ID of the place, in `places/{place_id}` format. + */ + public Builder placeId(Optional placeId) { + Utils.checkNotNull(placeId, "placeId"); + this.placeId = placeId; + return this; + } + + + /** + * Title of the place. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + /** + * Title of the place. + */ + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * URI reference of the place. + */ + public Builder url(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + /** + * URI reference of the place. + */ + public Builder url(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + + /** + * Snippets of reviews that are used to generate answers about the + * features of a given place in Google Maps. + */ + public Builder reviewSnippets(List reviewSnippets) { + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.reviewSnippets = Optional.ofNullable(reviewSnippets); + return this; + } + + /** + * Snippets of reviews that are used to generate answers about the + * features of a given place in Google Maps. + */ + public Builder reviewSnippets(Optional> reviewSnippets) { + Utils.checkNotNull(reviewSnippets, "reviewSnippets"); + this.reviewSnippets = reviewSnippets; + return this; + } + + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public Builder startIndex(int startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = Optional.ofNullable(startIndex); + return this; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public Builder startIndex(Optional startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = startIndex; + return this; + } + + + /** + * End of the attributed segment, exclusive. + */ + public Builder endIndex(int endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = Optional.ofNullable(endIndex); + return this; + } + + /** + * End of the attributed segment, exclusive. + */ + public Builder endIndex(Optional endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = endIndex; + return this; + } + + public PlaceCitation build() { + + return new PlaceCitation( + placeId, name, url, + reviewSnippets, startIndex, endIndex); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"place_citation\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/RagResource.java b/src/main/java/com/google/genai/gaos/models/interactions/RagResource.java new file mode 100644 index 00000000000..56fdf0ac6ac --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/RagResource.java @@ -0,0 +1,218 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * RagResource + * + *

The definition of the Rag resource. + */ +@SuppressWarnings("all") +public class RagResource { + /** + * Optional. RagCorpora resource name. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("rag_corpus") + private Optional ragCorpus; + + /** + * Optional. rag_file_id. The files should be in the same rag_corpus set in + * rag_corpus field. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("rag_file_ids") + private Optional> ragFileIds; + + @JsonCreator + public RagResource( + @JsonProperty("rag_corpus") Optional ragCorpus, + @JsonProperty("rag_file_ids") Optional> ragFileIds) { + Utils.checkNotNull(ragCorpus, "ragCorpus"); + Utils.checkNotNull(ragFileIds, "ragFileIds"); + this.ragCorpus = ragCorpus; + this.ragFileIds = ragFileIds; + } + + public RagResource() { + this(Optional.empty(), Optional.empty()); + } + + /** + * Optional. RagCorpora resource name. + */ + @JsonIgnore + public Optional ragCorpus() { + return ragCorpus; + } + + /** + * Optional. rag_file_id. The files should be in the same rag_corpus set in + * rag_corpus field. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> ragFileIds() { + return (Optional>) ragFileIds; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. RagCorpora resource name. + */ + public RagResource withRagCorpus(String ragCorpus) { + Utils.checkNotNull(ragCorpus, "ragCorpus"); + this.ragCorpus = Optional.ofNullable(ragCorpus); + return this; + } + + + /** + * Optional. RagCorpora resource name. + */ + public RagResource withRagCorpus(Optional ragCorpus) { + Utils.checkNotNull(ragCorpus, "ragCorpus"); + this.ragCorpus = ragCorpus; + return this; + } + + /** + * Optional. rag_file_id. The files should be in the same rag_corpus set in + * rag_corpus field. + */ + public RagResource withRagFileIds(List ragFileIds) { + Utils.checkNotNull(ragFileIds, "ragFileIds"); + this.ragFileIds = Optional.ofNullable(ragFileIds); + return this; + } + + + /** + * Optional. rag_file_id. The files should be in the same rag_corpus set in + * rag_corpus field. + */ + public RagResource withRagFileIds(Optional> ragFileIds) { + Utils.checkNotNull(ragFileIds, "ragFileIds"); + this.ragFileIds = ragFileIds; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RagResource other = (RagResource) o; + return + Utils.enhancedDeepEquals(this.ragCorpus, other.ragCorpus) && + Utils.enhancedDeepEquals(this.ragFileIds, other.ragFileIds); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ragCorpus, ragFileIds); + } + + @Override + public String toString() { + return Utils.toString(RagResource.class, + "ragCorpus", ragCorpus, + "ragFileIds", ragFileIds); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional ragCorpus = Optional.empty(); + + private Optional> ragFileIds = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. RagCorpora resource name. + */ + public Builder ragCorpus(String ragCorpus) { + Utils.checkNotNull(ragCorpus, "ragCorpus"); + this.ragCorpus = Optional.ofNullable(ragCorpus); + return this; + } + + /** + * Optional. RagCorpora resource name. + */ + public Builder ragCorpus(Optional ragCorpus) { + Utils.checkNotNull(ragCorpus, "ragCorpus"); + this.ragCorpus = ragCorpus; + return this; + } + + + /** + * Optional. rag_file_id. The files should be in the same rag_corpus set in + * rag_corpus field. + */ + public Builder ragFileIds(List ragFileIds) { + Utils.checkNotNull(ragFileIds, "ragFileIds"); + this.ragFileIds = Optional.ofNullable(ragFileIds); + return this; + } + + /** + * Optional. rag_file_id. The files should be in the same rag_corpus set in + * rag_corpus field. + */ + public Builder ragFileIds(Optional> ragFileIds) { + Utils.checkNotNull(ragFileIds, "ragFileIds"); + this.ragFileIds = ragFileIds; + return this; + } + + public RagResource build() { + + return new RagResource( + ragCorpus, ragFileIds); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/RagRetrievalConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/RagRetrievalConfig.java new file mode 100644 index 00000000000..afaed177843 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/RagRetrievalConfig.java @@ -0,0 +1,337 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * RagRetrievalConfig + * + *

Specifies the context retrieval config. + */ +@SuppressWarnings("all") +public class RagRetrievalConfig { + /** + * Optional. The number of contexts to retrieve. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("top_k") + private Optional topK; + + /** + * Config for Hybrid Search. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("hybrid_search") + private Optional hybridSearch; + + /** + * Config for filters. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("filter") + private Optional filter; + + /** + * Config for Rank Service. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("ranking") + private Optional ranking; + + @JsonCreator + public RagRetrievalConfig( + @JsonProperty("top_k") Optional topK, + @JsonProperty("hybrid_search") Optional hybridSearch, + @JsonProperty("filter") Optional filter, + @JsonProperty("ranking") Optional ranking) { + Utils.checkNotNull(topK, "topK"); + Utils.checkNotNull(hybridSearch, "hybridSearch"); + Utils.checkNotNull(filter, "filter"); + Utils.checkNotNull(ranking, "ranking"); + this.topK = topK; + this.hybridSearch = hybridSearch; + this.filter = filter; + this.ranking = ranking; + } + + public RagRetrievalConfig() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + /** + * Optional. The number of contexts to retrieve. + */ + @JsonIgnore + public Optional topK() { + return topK; + } + + /** + * Config for Hybrid Search. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional hybridSearch() { + return (Optional) hybridSearch; + } + + /** + * Config for filters. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional filter() { + return (Optional) filter; + } + + /** + * Config for Rank Service. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional ranking() { + return (Optional) ranking; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. The number of contexts to retrieve. + */ + public RagRetrievalConfig withTopK(int topK) { + Utils.checkNotNull(topK, "topK"); + this.topK = Optional.ofNullable(topK); + return this; + } + + + /** + * Optional. The number of contexts to retrieve. + */ + public RagRetrievalConfig withTopK(Optional topK) { + Utils.checkNotNull(topK, "topK"); + this.topK = topK; + return this; + } + + /** + * Config for Hybrid Search. + */ + public RagRetrievalConfig withHybridSearch(HybridSearch hybridSearch) { + Utils.checkNotNull(hybridSearch, "hybridSearch"); + this.hybridSearch = Optional.ofNullable(hybridSearch); + return this; + } + + + /** + * Config for Hybrid Search. + */ + public RagRetrievalConfig withHybridSearch(Optional hybridSearch) { + Utils.checkNotNull(hybridSearch, "hybridSearch"); + this.hybridSearch = hybridSearch; + return this; + } + + /** + * Config for filters. + */ + public RagRetrievalConfig withFilter(Filter filter) { + Utils.checkNotNull(filter, "filter"); + this.filter = Optional.ofNullable(filter); + return this; + } + + + /** + * Config for filters. + */ + public RagRetrievalConfig withFilter(Optional filter) { + Utils.checkNotNull(filter, "filter"); + this.filter = filter; + return this; + } + + /** + * Config for Rank Service. + */ + public RagRetrievalConfig withRanking(Ranking ranking) { + Utils.checkNotNull(ranking, "ranking"); + this.ranking = Optional.ofNullable(ranking); + return this; + } + + + /** + * Config for Rank Service. + */ + public RagRetrievalConfig withRanking(Optional ranking) { + Utils.checkNotNull(ranking, "ranking"); + this.ranking = ranking; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RagRetrievalConfig other = (RagRetrievalConfig) o; + return + Utils.enhancedDeepEquals(this.topK, other.topK) && + Utils.enhancedDeepEquals(this.hybridSearch, other.hybridSearch) && + Utils.enhancedDeepEquals(this.filter, other.filter) && + Utils.enhancedDeepEquals(this.ranking, other.ranking); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + topK, hybridSearch, filter, + ranking); + } + + @Override + public String toString() { + return Utils.toString(RagRetrievalConfig.class, + "topK", topK, + "hybridSearch", hybridSearch, + "filter", filter, + "ranking", ranking); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional topK = Optional.empty(); + + private Optional hybridSearch = Optional.empty(); + + private Optional filter = Optional.empty(); + + private Optional ranking = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. The number of contexts to retrieve. + */ + public Builder topK(int topK) { + Utils.checkNotNull(topK, "topK"); + this.topK = Optional.ofNullable(topK); + return this; + } + + /** + * Optional. The number of contexts to retrieve. + */ + public Builder topK(Optional topK) { + Utils.checkNotNull(topK, "topK"); + this.topK = topK; + return this; + } + + + /** + * Config for Hybrid Search. + */ + public Builder hybridSearch(HybridSearch hybridSearch) { + Utils.checkNotNull(hybridSearch, "hybridSearch"); + this.hybridSearch = Optional.ofNullable(hybridSearch); + return this; + } + + /** + * Config for Hybrid Search. + */ + public Builder hybridSearch(Optional hybridSearch) { + Utils.checkNotNull(hybridSearch, "hybridSearch"); + this.hybridSearch = hybridSearch; + return this; + } + + + /** + * Config for filters. + */ + public Builder filter(Filter filter) { + Utils.checkNotNull(filter, "filter"); + this.filter = Optional.ofNullable(filter); + return this; + } + + /** + * Config for filters. + */ + public Builder filter(Optional filter) { + Utils.checkNotNull(filter, "filter"); + this.filter = filter; + return this; + } + + + /** + * Config for Rank Service. + */ + public Builder ranking(Ranking ranking) { + Utils.checkNotNull(ranking, "ranking"); + this.ranking = Optional.ofNullable(ranking); + return this; + } + + /** + * Config for Rank Service. + */ + public Builder ranking(Optional ranking) { + Utils.checkNotNull(ranking, "ranking"); + this.ranking = ranking; + return this; + } + + public RagRetrievalConfig build() { + + return new RagRetrievalConfig( + topK, hybridSearch, filter, + ranking); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/RagStoreConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/RagStoreConfig.java new file mode 100644 index 00000000000..9b308a41b41 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/RagStoreConfig.java @@ -0,0 +1,377 @@ +/* +* 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.JsonIgnore; +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 java.lang.Deprecated; +import java.lang.Double; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * RagStoreConfig + * + *

Use to specify configuration for RAG Store. + */ +@SuppressWarnings("all") +public class RagStoreConfig { + /** + * Optional. The representation of the rag source. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("rag_resources") + private Optional> ragResources; + + /** + * Optional. Number of top k results to return from the selected corpora. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("similarity_top_k") + @Deprecated + private Optional similarityTopK; + + /** + * Optional. Only return results with vector distance smaller than the threshold. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("vector_distance_threshold") + @Deprecated + private Optional vectorDistanceThreshold; + + /** + * Specifies the context retrieval config. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("rag_retrieval_config") + private Optional ragRetrievalConfig; + + @JsonCreator + public RagStoreConfig( + @JsonProperty("rag_resources") Optional> ragResources, + @JsonProperty("similarity_top_k") Optional similarityTopK, + @JsonProperty("vector_distance_threshold") Optional vectorDistanceThreshold, + @JsonProperty("rag_retrieval_config") Optional ragRetrievalConfig) { + Utils.checkNotNull(ragResources, "ragResources"); + Utils.checkNotNull(similarityTopK, "similarityTopK"); + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + Utils.checkNotNull(ragRetrievalConfig, "ragRetrievalConfig"); + this.ragResources = ragResources; + this.similarityTopK = similarityTopK; + this.vectorDistanceThreshold = vectorDistanceThreshold; + this.ragRetrievalConfig = ragRetrievalConfig; + } + + public RagStoreConfig() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + /** + * Optional. The representation of the rag source. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> ragResources() { + return (Optional>) ragResources; + } + + /** + * Optional. Number of top k results to return from the selected corpora. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + @JsonIgnore + public Optional similarityTopK() { + return similarityTopK; + } + + /** + * Optional. Only return results with vector distance smaller than the threshold. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + @JsonIgnore + public Optional vectorDistanceThreshold() { + return vectorDistanceThreshold; + } + + /** + * Specifies the context retrieval config. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional ragRetrievalConfig() { + return (Optional) ragRetrievalConfig; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. The representation of the rag source. + */ + public RagStoreConfig withRagResources(List ragResources) { + Utils.checkNotNull(ragResources, "ragResources"); + this.ragResources = Optional.ofNullable(ragResources); + return this; + } + + + /** + * Optional. The representation of the rag source. + */ + public RagStoreConfig withRagResources(Optional> ragResources) { + Utils.checkNotNull(ragResources, "ragResources"); + this.ragResources = ragResources; + return this; + } + + /** + * Optional. Number of top k results to return from the selected corpora. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public RagStoreConfig withSimilarityTopK(int similarityTopK) { + Utils.checkNotNull(similarityTopK, "similarityTopK"); + this.similarityTopK = Optional.ofNullable(similarityTopK); + return this; + } + + + /** + * Optional. Number of top k results to return from the selected corpora. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public RagStoreConfig withSimilarityTopK(Optional similarityTopK) { + Utils.checkNotNull(similarityTopK, "similarityTopK"); + this.similarityTopK = similarityTopK; + return this; + } + + /** + * Optional. Only return results with vector distance smaller than the threshold. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public RagStoreConfig withVectorDistanceThreshold(double vectorDistanceThreshold) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + this.vectorDistanceThreshold = Optional.ofNullable(vectorDistanceThreshold); + return this; + } + + + /** + * Optional. Only return results with vector distance smaller than the threshold. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public RagStoreConfig withVectorDistanceThreshold(Optional vectorDistanceThreshold) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + this.vectorDistanceThreshold = vectorDistanceThreshold; + return this; + } + + /** + * Specifies the context retrieval config. + */ + public RagStoreConfig withRagRetrievalConfig(RagRetrievalConfig ragRetrievalConfig) { + Utils.checkNotNull(ragRetrievalConfig, "ragRetrievalConfig"); + this.ragRetrievalConfig = Optional.ofNullable(ragRetrievalConfig); + return this; + } + + + /** + * Specifies the context retrieval config. + */ + public RagStoreConfig withRagRetrievalConfig(Optional ragRetrievalConfig) { + Utils.checkNotNull(ragRetrievalConfig, "ragRetrievalConfig"); + this.ragRetrievalConfig = ragRetrievalConfig; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RagStoreConfig other = (RagStoreConfig) o; + return + Utils.enhancedDeepEquals(this.ragResources, other.ragResources) && + Utils.enhancedDeepEquals(this.similarityTopK, other.similarityTopK) && + Utils.enhancedDeepEquals(this.vectorDistanceThreshold, other.vectorDistanceThreshold) && + Utils.enhancedDeepEquals(this.ragRetrievalConfig, other.ragRetrievalConfig); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ragResources, similarityTopK, vectorDistanceThreshold, + ragRetrievalConfig); + } + + @Override + public String toString() { + return Utils.toString(RagStoreConfig.class, + "ragResources", ragResources, + "similarityTopK", similarityTopK, + "vectorDistanceThreshold", vectorDistanceThreshold, + "ragRetrievalConfig", ragRetrievalConfig); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> ragResources = Optional.empty(); + + @Deprecated + private Optional similarityTopK = Optional.empty(); + + @Deprecated + private Optional vectorDistanceThreshold = Optional.empty(); + + private Optional ragRetrievalConfig = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. The representation of the rag source. + */ + public Builder ragResources(List ragResources) { + Utils.checkNotNull(ragResources, "ragResources"); + this.ragResources = Optional.ofNullable(ragResources); + return this; + } + + /** + * Optional. The representation of the rag source. + */ + public Builder ragResources(Optional> ragResources) { + Utils.checkNotNull(ragResources, "ragResources"); + this.ragResources = ragResources; + return this; + } + + + /** + * Optional. Number of top k results to return from the selected corpora. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder similarityTopK(int similarityTopK) { + Utils.checkNotNull(similarityTopK, "similarityTopK"); + this.similarityTopK = Optional.ofNullable(similarityTopK); + return this; + } + + /** + * Optional. Number of top k results to return from the selected corpora. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder similarityTopK(Optional similarityTopK) { + Utils.checkNotNull(similarityTopK, "similarityTopK"); + this.similarityTopK = similarityTopK; + return this; + } + + + /** + * Optional. Only return results with vector distance smaller than the threshold. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder vectorDistanceThreshold(double vectorDistanceThreshold) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + this.vectorDistanceThreshold = Optional.ofNullable(vectorDistanceThreshold); + return this; + } + + /** + * Optional. Only return results with vector distance smaller than the threshold. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder vectorDistanceThreshold(Optional vectorDistanceThreshold) { + Utils.checkNotNull(vectorDistanceThreshold, "vectorDistanceThreshold"); + this.vectorDistanceThreshold = vectorDistanceThreshold; + return this; + } + + + /** + * Specifies the context retrieval config. + */ + public Builder ragRetrievalConfig(RagRetrievalConfig ragRetrievalConfig) { + Utils.checkNotNull(ragRetrievalConfig, "ragRetrievalConfig"); + this.ragRetrievalConfig = Optional.ofNullable(ragRetrievalConfig); + return this; + } + + /** + * Specifies the context retrieval config. + */ + public Builder ragRetrievalConfig(Optional ragRetrievalConfig) { + Utils.checkNotNull(ragRetrievalConfig, "ragRetrievalConfig"); + this.ragRetrievalConfig = ragRetrievalConfig; + return this; + } + + public RagStoreConfig build() { + + return new RagStoreConfig( + ragResources, similarityTopK, vectorDistanceThreshold, + ragRetrievalConfig); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Ranking.java b/src/main/java/com/google/genai/gaos/models/interactions/Ranking.java new file mode 100644 index 00000000000..85d97807973 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Ranking.java @@ -0,0 +1,169 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * Ranking + * + *

Config for Rank Service. + */ +@SuppressWarnings("all") +public class Ranking { + + @JsonProperty("ranking_config") + private String rankingConfig; + + /** + * Optional. The model name of the rank service. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("model_name") + private Optional modelName; + + @JsonCreator + public Ranking( + @JsonProperty("model_name") Optional modelName) { + Utils.checkNotNull(modelName, "modelName"); + this.rankingConfig = Builder._SINGLETON_VALUE_RankingConfig.value(); + this.modelName = modelName; + } + + public Ranking() { + this(Optional.empty()); + } + + @JsonIgnore + public String rankingConfig() { + return rankingConfig; + } + + /** + * Optional. The model name of the rank service. + */ + @JsonIgnore + public Optional modelName() { + return modelName; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. The model name of the rank service. + */ + public Ranking withModelName(String modelName) { + Utils.checkNotNull(modelName, "modelName"); + this.modelName = Optional.ofNullable(modelName); + return this; + } + + + /** + * Optional. The model name of the rank service. + */ + public Ranking withModelName(Optional modelName) { + Utils.checkNotNull(modelName, "modelName"); + this.modelName = modelName; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Ranking other = (Ranking) o; + return + Utils.enhancedDeepEquals(this.rankingConfig, other.rankingConfig) && + Utils.enhancedDeepEquals(this.modelName, other.modelName); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + rankingConfig, modelName); + } + + @Override + public String toString() { + return Utils.toString(Ranking.class, + "rankingConfig", rankingConfig, + "modelName", modelName); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional modelName = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. The model name of the rank service. + */ + public Builder modelName(String modelName) { + Utils.checkNotNull(modelName, "modelName"); + this.modelName = Optional.ofNullable(modelName); + return this; + } + + /** + * Optional. The model name of the rank service. + */ + public Builder modelName(Optional modelName) { + Utils.checkNotNull(modelName, "modelName"); + this.modelName = modelName; + return this; + } + + public Ranking build() { + + return new Ranking( + modelName); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_RankingConfig = + new LazySingletonValue<>( + "ranking_config", + "\"rank_service\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ResponseFormat.java b/src/main/java/com/google/genai/gaos/models/interactions/ResponseFormat.java new file mode 100644 index 00000000000..1ac0d04a74f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ResponseFormat.java @@ -0,0 +1,134 @@ +/* +* 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.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.Object; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Map; + +@JsonDeserialize(using = ResponseFormat._Deserializer.class) +@SuppressWarnings("all") +public class ResponseFormat { + + @JsonValue + private final TypedObject value; + + private ResponseFormat(TypedObject value) { + this.value = value; + } + + public static ResponseFormat of(AudioResponseFormat value) { + Utils.checkNotNull(value, "value"); + return new ResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static ResponseFormat of(TextResponseFormat value) { + Utils.checkNotNull(value, "value"); + return new ResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static ResponseFormat of(ImageResponseFormat value) { + Utils.checkNotNull(value, "value"); + return new ResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static ResponseFormat of(VideoResponseFormat value) { + Utils.checkNotNull(value, "value"); + return new ResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static ResponseFormat of(Map value) { + Utils.checkNotNull(value, "value"); + return new ResponseFormat(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.AudioResponseFormat}
  • + *
  • {@code com.google.genai.gaos.models.interactions.TextResponseFormat}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ImageResponseFormat}
  • + *
  • {@code com.google.genai.gaos.models.interactions.VideoResponseFormat}
  • + *
  • {@code java.util.Map}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResponseFormat other = (ResponseFormat) 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(ResponseFormat.class, false, + 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)); + } + } + + @Override + public String toString() { + return Utils.toString(ResponseFormat.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ResponseModality.java b/src/main/java/com/google/genai/gaos/models/interactions/ResponseModality.java new file mode 100644 index 00000000000..27f3fdbbf25 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ResponseModality.java @@ -0,0 +1,55 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum ResponseModality { + TEXT("text"), + IMAGE("image"), + AUDIO("audio"), + VIDEO("video"), + DOCUMENT("document"); + + @JsonValue + private final String value; + + ResponseModality(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ResponseModality o: ResponseModality.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Retrieval.java b/src/main/java/com/google/genai/gaos/models/interactions/Retrieval.java new file mode 100644 index 00000000000..de9dc193e3d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Retrieval.java @@ -0,0 +1,419 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * Retrieval + * + *

A tool that can be used by the model to retrieve files. + */ +@SuppressWarnings("all") +public class Retrieval { + + @JsonProperty("type") + private String type; + + /** + * The types of file retrieval to enable. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("retrieval_types") + private Optional> retrievalTypes; + + /** + * Used to specify configuration for VertexAISearch. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("vertex_ai_search_config") + private Optional vertexAiSearchConfig; + + /** + * Used to specify configuration for ExaAISearch. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("exa_ai_search_config") + private Optional exaAiSearchConfig; + + /** + * Used to specify configuration for ParallelAISearch. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("parallel_ai_search_config") + private Optional parallelAiSearchConfig; + + /** + * Use to specify configuration for RAG Store. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("rag_store_config") + private Optional ragStoreConfig; + + @JsonCreator + public Retrieval( + @JsonProperty("retrieval_types") Optional> retrievalTypes, + @JsonProperty("vertex_ai_search_config") Optional vertexAiSearchConfig, + @JsonProperty("exa_ai_search_config") Optional exaAiSearchConfig, + @JsonProperty("parallel_ai_search_config") Optional parallelAiSearchConfig, + @JsonProperty("rag_store_config") Optional ragStoreConfig) { + Utils.checkNotNull(retrievalTypes, "retrievalTypes"); + Utils.checkNotNull(vertexAiSearchConfig, "vertexAiSearchConfig"); + Utils.checkNotNull(exaAiSearchConfig, "exaAiSearchConfig"); + Utils.checkNotNull(parallelAiSearchConfig, "parallelAiSearchConfig"); + Utils.checkNotNull(ragStoreConfig, "ragStoreConfig"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.retrievalTypes = retrievalTypes; + this.vertexAiSearchConfig = vertexAiSearchConfig; + this.exaAiSearchConfig = exaAiSearchConfig; + this.parallelAiSearchConfig = parallelAiSearchConfig; + this.ragStoreConfig = ragStoreConfig; + } + + public Retrieval() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The types of file retrieval to enable. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> retrievalTypes() { + return (Optional>) retrievalTypes; + } + + /** + * Used to specify configuration for VertexAISearch. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional vertexAiSearchConfig() { + return (Optional) vertexAiSearchConfig; + } + + /** + * Used to specify configuration for ExaAISearch. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional exaAiSearchConfig() { + return (Optional) exaAiSearchConfig; + } + + /** + * Used to specify configuration for ParallelAISearch. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional parallelAiSearchConfig() { + return (Optional) parallelAiSearchConfig; + } + + /** + * Use to specify configuration for RAG Store. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional ragStoreConfig() { + return (Optional) ragStoreConfig; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The types of file retrieval to enable. + */ + public Retrieval withRetrievalTypes(List retrievalTypes) { + Utils.checkNotNull(retrievalTypes, "retrievalTypes"); + this.retrievalTypes = Optional.ofNullable(retrievalTypes); + return this; + } + + + /** + * The types of file retrieval to enable. + */ + public Retrieval withRetrievalTypes(Optional> retrievalTypes) { + Utils.checkNotNull(retrievalTypes, "retrievalTypes"); + this.retrievalTypes = retrievalTypes; + return this; + } + + /** + * Used to specify configuration for VertexAISearch. + */ + public Retrieval withVertexAiSearchConfig(VertexAISearchConfig vertexAiSearchConfig) { + Utils.checkNotNull(vertexAiSearchConfig, "vertexAiSearchConfig"); + this.vertexAiSearchConfig = Optional.ofNullable(vertexAiSearchConfig); + return this; + } + + + /** + * Used to specify configuration for VertexAISearch. + */ + public Retrieval withVertexAiSearchConfig(Optional vertexAiSearchConfig) { + Utils.checkNotNull(vertexAiSearchConfig, "vertexAiSearchConfig"); + this.vertexAiSearchConfig = vertexAiSearchConfig; + return this; + } + + /** + * Used to specify configuration for ExaAISearch. + */ + public Retrieval withExaAiSearchConfig(ExaAISearchConfig exaAiSearchConfig) { + Utils.checkNotNull(exaAiSearchConfig, "exaAiSearchConfig"); + this.exaAiSearchConfig = Optional.ofNullable(exaAiSearchConfig); + return this; + } + + + /** + * Used to specify configuration for ExaAISearch. + */ + public Retrieval withExaAiSearchConfig(Optional exaAiSearchConfig) { + Utils.checkNotNull(exaAiSearchConfig, "exaAiSearchConfig"); + this.exaAiSearchConfig = exaAiSearchConfig; + return this; + } + + /** + * Used to specify configuration for ParallelAISearch. + */ + public Retrieval withParallelAiSearchConfig(ParallelAISearchConfig parallelAiSearchConfig) { + Utils.checkNotNull(parallelAiSearchConfig, "parallelAiSearchConfig"); + this.parallelAiSearchConfig = Optional.ofNullable(parallelAiSearchConfig); + return this; + } + + + /** + * Used to specify configuration for ParallelAISearch. + */ + public Retrieval withParallelAiSearchConfig(Optional parallelAiSearchConfig) { + Utils.checkNotNull(parallelAiSearchConfig, "parallelAiSearchConfig"); + this.parallelAiSearchConfig = parallelAiSearchConfig; + return this; + } + + /** + * Use to specify configuration for RAG Store. + */ + public Retrieval withRagStoreConfig(RagStoreConfig ragStoreConfig) { + Utils.checkNotNull(ragStoreConfig, "ragStoreConfig"); + this.ragStoreConfig = Optional.ofNullable(ragStoreConfig); + return this; + } + + + /** + * Use to specify configuration for RAG Store. + */ + public Retrieval withRagStoreConfig(Optional ragStoreConfig) { + Utils.checkNotNull(ragStoreConfig, "ragStoreConfig"); + this.ragStoreConfig = ragStoreConfig; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Retrieval other = (Retrieval) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.retrievalTypes, other.retrievalTypes) && + Utils.enhancedDeepEquals(this.vertexAiSearchConfig, other.vertexAiSearchConfig) && + Utils.enhancedDeepEquals(this.exaAiSearchConfig, other.exaAiSearchConfig) && + Utils.enhancedDeepEquals(this.parallelAiSearchConfig, other.parallelAiSearchConfig) && + Utils.enhancedDeepEquals(this.ragStoreConfig, other.ragStoreConfig); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, retrievalTypes, vertexAiSearchConfig, + exaAiSearchConfig, parallelAiSearchConfig, ragStoreConfig); + } + + @Override + public String toString() { + return Utils.toString(Retrieval.class, + "type", type, + "retrievalTypes", retrievalTypes, + "vertexAiSearchConfig", vertexAiSearchConfig, + "exaAiSearchConfig", exaAiSearchConfig, + "parallelAiSearchConfig", parallelAiSearchConfig, + "ragStoreConfig", ragStoreConfig); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> retrievalTypes = Optional.empty(); + + private Optional vertexAiSearchConfig = Optional.empty(); + + private Optional exaAiSearchConfig = Optional.empty(); + + private Optional parallelAiSearchConfig = Optional.empty(); + + private Optional ragStoreConfig = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The types of file retrieval to enable. + */ + public Builder retrievalTypes(List retrievalTypes) { + Utils.checkNotNull(retrievalTypes, "retrievalTypes"); + this.retrievalTypes = Optional.ofNullable(retrievalTypes); + return this; + } + + /** + * The types of file retrieval to enable. + */ + public Builder retrievalTypes(Optional> retrievalTypes) { + Utils.checkNotNull(retrievalTypes, "retrievalTypes"); + this.retrievalTypes = retrievalTypes; + return this; + } + + + /** + * Used to specify configuration for VertexAISearch. + */ + public Builder vertexAiSearchConfig(VertexAISearchConfig vertexAiSearchConfig) { + Utils.checkNotNull(vertexAiSearchConfig, "vertexAiSearchConfig"); + this.vertexAiSearchConfig = Optional.ofNullable(vertexAiSearchConfig); + return this; + } + + /** + * Used to specify configuration for VertexAISearch. + */ + public Builder vertexAiSearchConfig(Optional vertexAiSearchConfig) { + Utils.checkNotNull(vertexAiSearchConfig, "vertexAiSearchConfig"); + this.vertexAiSearchConfig = vertexAiSearchConfig; + return this; + } + + + /** + * Used to specify configuration for ExaAISearch. + */ + public Builder exaAiSearchConfig(ExaAISearchConfig exaAiSearchConfig) { + Utils.checkNotNull(exaAiSearchConfig, "exaAiSearchConfig"); + this.exaAiSearchConfig = Optional.ofNullable(exaAiSearchConfig); + return this; + } + + /** + * Used to specify configuration for ExaAISearch. + */ + public Builder exaAiSearchConfig(Optional exaAiSearchConfig) { + Utils.checkNotNull(exaAiSearchConfig, "exaAiSearchConfig"); + this.exaAiSearchConfig = exaAiSearchConfig; + return this; + } + + + /** + * Used to specify configuration for ParallelAISearch. + */ + public Builder parallelAiSearchConfig(ParallelAISearchConfig parallelAiSearchConfig) { + Utils.checkNotNull(parallelAiSearchConfig, "parallelAiSearchConfig"); + this.parallelAiSearchConfig = Optional.ofNullable(parallelAiSearchConfig); + return this; + } + + /** + * Used to specify configuration for ParallelAISearch. + */ + public Builder parallelAiSearchConfig(Optional parallelAiSearchConfig) { + Utils.checkNotNull(parallelAiSearchConfig, "parallelAiSearchConfig"); + this.parallelAiSearchConfig = parallelAiSearchConfig; + return this; + } + + + /** + * Use to specify configuration for RAG Store. + */ + public Builder ragStoreConfig(RagStoreConfig ragStoreConfig) { + Utils.checkNotNull(ragStoreConfig, "ragStoreConfig"); + this.ragStoreConfig = Optional.ofNullable(ragStoreConfig); + return this; + } + + /** + * Use to specify configuration for RAG Store. + */ + public Builder ragStoreConfig(Optional ragStoreConfig) { + Utils.checkNotNull(ragStoreConfig, "ragStoreConfig"); + this.ragStoreConfig = ragStoreConfig; + return this; + } + + public Retrieval build() { + + return new Retrieval( + retrievalTypes, vertexAiSearchConfig, exaAiSearchConfig, + parallelAiSearchConfig, ragStoreConfig); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"retrieval\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/RetrievalType.java b/src/main/java/com/google/genai/gaos/models/interactions/RetrievalType.java new file mode 100644 index 00000000000..c8ce24c2bf5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/RetrievalType.java @@ -0,0 +1,54 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum RetrievalType { + VERTEX_AI_SEARCH("vertex_ai_search"), + RAG_STORE("rag_store"), + EXA_AI_SEARCH("exa_ai_search"), + PARALLEL_AI_SEARCH("parallel_ai_search"); + + @JsonValue + private final String value; + + RetrievalType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (RetrievalType o: RetrievalType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ReviewSnippet.java b/src/main/java/com/google/genai/gaos/models/interactions/ReviewSnippet.java new file mode 100644 index 00000000000..5b45b8b6775 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ReviewSnippet.java @@ -0,0 +1,270 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * ReviewSnippet + * + *

Encapsulates a snippet of a user review that answers a question about + * the features of a specific place in Google Maps. + */ +@SuppressWarnings("all") +public class ReviewSnippet { + /** + * Title of the review. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("title") + private Optional title; + + /** + * A link that corresponds to the user review on Google Maps. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("url") + private Optional url; + + /** + * The ID of the review snippet. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("review_id") + private Optional reviewId; + + @JsonCreator + public ReviewSnippet( + @JsonProperty("title") Optional title, + @JsonProperty("url") Optional url, + @JsonProperty("review_id") Optional reviewId) { + Utils.checkNotNull(title, "title"); + Utils.checkNotNull(url, "url"); + Utils.checkNotNull(reviewId, "reviewId"); + this.title = title; + this.url = url; + this.reviewId = reviewId; + } + + public ReviewSnippet() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * Title of the review. + */ + @JsonIgnore + public Optional title() { + return title; + } + + /** + * A link that corresponds to the user review on Google Maps. + */ + @JsonIgnore + public Optional url() { + return url; + } + + /** + * The ID of the review snippet. + */ + @JsonIgnore + public Optional reviewId() { + return reviewId; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Title of the review. + */ + public ReviewSnippet withTitle(String title) { + Utils.checkNotNull(title, "title"); + this.title = Optional.ofNullable(title); + return this; + } + + + /** + * Title of the review. + */ + public ReviewSnippet withTitle(Optional title) { + Utils.checkNotNull(title, "title"); + this.title = title; + return this; + } + + /** + * A link that corresponds to the user review on Google Maps. + */ + public ReviewSnippet withUrl(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + + /** + * A link that corresponds to the user review on Google Maps. + */ + public ReviewSnippet withUrl(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + /** + * The ID of the review snippet. + */ + public ReviewSnippet withReviewId(String reviewId) { + Utils.checkNotNull(reviewId, "reviewId"); + this.reviewId = Optional.ofNullable(reviewId); + return this; + } + + + /** + * The ID of the review snippet. + */ + public ReviewSnippet withReviewId(Optional reviewId) { + Utils.checkNotNull(reviewId, "reviewId"); + this.reviewId = reviewId; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReviewSnippet other = (ReviewSnippet) o; + return + Utils.enhancedDeepEquals(this.title, other.title) && + Utils.enhancedDeepEquals(this.url, other.url) && + Utils.enhancedDeepEquals(this.reviewId, other.reviewId); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + title, url, reviewId); + } + + @Override + public String toString() { + return Utils.toString(ReviewSnippet.class, + "title", title, + "url", url, + "reviewId", reviewId); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional title = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional reviewId = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Title of the review. + */ + public Builder title(String title) { + Utils.checkNotNull(title, "title"); + this.title = Optional.ofNullable(title); + return this; + } + + /** + * Title of the review. + */ + public Builder title(Optional title) { + Utils.checkNotNull(title, "title"); + this.title = title; + return this; + } + + + /** + * A link that corresponds to the user review on Google Maps. + */ + public Builder url(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + /** + * A link that corresponds to the user review on Google Maps. + */ + public Builder url(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + + /** + * The ID of the review snippet. + */ + public Builder reviewId(String reviewId) { + Utils.checkNotNull(reviewId, "reviewId"); + this.reviewId = Optional.ofNullable(reviewId); + return this; + } + + /** + * The ID of the review snippet. + */ + public Builder reviewId(Optional reviewId) { + Utils.checkNotNull(reviewId, "reviewId"); + this.reviewId = reviewId; + return this; + } + + public ReviewSnippet build() { + + return new ReviewSnippet( + title, url, reviewId); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ServiceTier.java b/src/main/java/com/google/genai/gaos/models/interactions/ServiceTier.java new file mode 100644 index 00000000000..db45aa34b0b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ServiceTier.java @@ -0,0 +1,53 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum ServiceTier { + FLEX("flex"), + STANDARD("standard"), + PRIORITY("priority"); + + @JsonValue + private final String value; + + ServiceTier(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ServiceTier o: ServiceTier.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + 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 new file mode 100644 index 00000000000..321a56931ba --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Source.java @@ -0,0 +1,389 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * Source + * + *

A source to be mounted into the environment. + */ +@SuppressWarnings("all") +public class Source { + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("type") + private Optional type; + + /** + * The source of the environment. + * For GCS, this is the GCS path. + * For GitHub, this is the GitHub path. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("source") + private Optional source; + + /** + * Where the source should appear in the environment. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("target") + private Optional target; + + /** + * The inline content if `type` is `INLINE`. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("content") + private Optional content; + + /** + * Optional encoding for inline content (e.g. `base64`). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("encoding") + private Optional encoding; + + @JsonCreator + public Source( + @JsonProperty("type") Optional type, + @JsonProperty("source") Optional source, + @JsonProperty("target") Optional target, + @JsonProperty("content") Optional content, + @JsonProperty("encoding") Optional encoding) { + Utils.checkNotNull(type, "type"); + Utils.checkNotNull(source, "source"); + Utils.checkNotNull(target, "target"); + Utils.checkNotNull(content, "content"); + Utils.checkNotNull(encoding, "encoding"); + this.type = type; + this.source = source; + this.target = target; + this.content = content; + this.encoding = encoding; + } + + public Source() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional type() { + return (Optional) type; + } + + /** + * The source of the environment. + * For GCS, this is the GCS path. + * For GitHub, this is the GitHub path. + */ + @JsonIgnore + public Optional source() { + return source; + } + + /** + * Where the source should appear in the environment. + */ + @JsonIgnore + public Optional target() { + return target; + } + + /** + * The inline content if `type` is `INLINE`. + */ + @JsonIgnore + public Optional content() { + return content; + } + + /** + * Optional encoding for inline content (e.g. `base64`). + */ + @JsonIgnore + public Optional encoding() { + return encoding; + } + + public static Builder builder() { + return new Builder(); + } + + + public Source withType(SourceType type) { + Utils.checkNotNull(type, "type"); + this.type = Optional.ofNullable(type); + return this; + } + + + public Source withType(Optional type) { + Utils.checkNotNull(type, "type"); + this.type = type; + return this; + } + + /** + * The source of the environment. + * For GCS, this is the GCS path. + * For GitHub, this is the GitHub path. + */ + public Source withSource(String source) { + Utils.checkNotNull(source, "source"); + this.source = Optional.ofNullable(source); + return this; + } + + + /** + * The source of the environment. + * For GCS, this is the GCS path. + * For GitHub, this is the GitHub path. + */ + public Source withSource(Optional source) { + Utils.checkNotNull(source, "source"); + this.source = source; + return this; + } + + /** + * Where the source should appear in the environment. + */ + public Source withTarget(String target) { + Utils.checkNotNull(target, "target"); + this.target = Optional.ofNullable(target); + return this; + } + + + /** + * Where the source should appear in the environment. + */ + public Source withTarget(Optional target) { + Utils.checkNotNull(target, "target"); + this.target = target; + return this; + } + + /** + * The inline content if `type` is `INLINE`. + */ + public Source withContent(String content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + + /** + * The inline content if `type` is `INLINE`. + */ + public Source withContent(Optional content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + /** + * Optional encoding for inline content (e.g. `base64`). + */ + public Source withEncoding(String encoding) { + Utils.checkNotNull(encoding, "encoding"); + this.encoding = Optional.ofNullable(encoding); + return this; + } + + + /** + * Optional encoding for inline content (e.g. `base64`). + */ + public Source withEncoding(Optional encoding) { + Utils.checkNotNull(encoding, "encoding"); + this.encoding = encoding; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Source other = (Source) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.source, other.source) && + Utils.enhancedDeepEquals(this.target, other.target) && + Utils.enhancedDeepEquals(this.content, other.content) && + Utils.enhancedDeepEquals(this.encoding, other.encoding); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, source, target, + content, encoding); + } + + @Override + public String toString() { + return Utils.toString(Source.class, + "type", type, + "source", source, + "target", target, + "content", content, + "encoding", encoding); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional type = Optional.empty(); + + private Optional source = Optional.empty(); + + private Optional target = Optional.empty(); + + private Optional content = Optional.empty(); + + private Optional encoding = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder type(SourceType type) { + Utils.checkNotNull(type, "type"); + this.type = Optional.ofNullable(type); + return this; + } + + public Builder type(Optional type) { + Utils.checkNotNull(type, "type"); + this.type = type; + return this; + } + + + /** + * The source of the environment. + * For GCS, this is the GCS path. + * For GitHub, this is the GitHub path. + */ + public Builder source(String source) { + Utils.checkNotNull(source, "source"); + this.source = Optional.ofNullable(source); + return this; + } + + /** + * The source of the environment. + * For GCS, this is the GCS path. + * For GitHub, this is the GitHub path. + */ + public Builder source(Optional source) { + Utils.checkNotNull(source, "source"); + this.source = source; + return this; + } + + + /** + * Where the source should appear in the environment. + */ + public Builder target(String target) { + Utils.checkNotNull(target, "target"); + this.target = Optional.ofNullable(target); + return this; + } + + /** + * Where the source should appear in the environment. + */ + public Builder target(Optional target) { + Utils.checkNotNull(target, "target"); + this.target = target; + return this; + } + + + /** + * The inline content if `type` is `INLINE`. + */ + public Builder content(String content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + /** + * The inline content if `type` is `INLINE`. + */ + public Builder content(Optional content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + + /** + * Optional encoding for inline content (e.g. `base64`). + */ + public Builder encoding(String encoding) { + Utils.checkNotNull(encoding, "encoding"); + this.encoding = Optional.ofNullable(encoding); + return this; + } + + /** + * Optional encoding for inline content (e.g. `base64`). + */ + public Builder encoding(Optional encoding) { + Utils.checkNotNull(encoding, "encoding"); + this.encoding = encoding; + return this; + } + + public Source build() { + + return new Source( + type, source, target, + content, encoding); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/SourceType.java b/src/main/java/com/google/genai/gaos/models/interactions/SourceType.java new file mode 100644 index 00000000000..c669a906d6a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/SourceType.java @@ -0,0 +1,54 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum SourceType { + GCS("gcs"), + INLINE("inline"), + REPOSITORY("repository"), + SKILL_REGISTRY("skill_registry"); + + @JsonValue + private final String value; + + SourceType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (SourceType o: SourceType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/SpeechConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/SpeechConfig.java new file mode 100644 index 00000000000..9b2bd791504 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/SpeechConfig.java @@ -0,0 +1,269 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * SpeechConfig + * + *

The configuration for speech interaction. + */ +@SuppressWarnings("all") +public class SpeechConfig { + /** + * The voice of the speaker. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("voice") + private Optional voice; + + /** + * The language of the speech. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("language") + private Optional language; + + /** + * The speaker's name, it should match the speaker name given in the prompt. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("speaker") + private Optional speaker; + + @JsonCreator + public SpeechConfig( + @JsonProperty("voice") Optional voice, + @JsonProperty("language") Optional language, + @JsonProperty("speaker") Optional speaker) { + Utils.checkNotNull(voice, "voice"); + Utils.checkNotNull(language, "language"); + Utils.checkNotNull(speaker, "speaker"); + this.voice = voice; + this.language = language; + this.speaker = speaker; + } + + public SpeechConfig() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * The voice of the speaker. + */ + @JsonIgnore + public Optional voice() { + return voice; + } + + /** + * The language of the speech. + */ + @JsonIgnore + public Optional language() { + return language; + } + + /** + * The speaker's name, it should match the speaker name given in the prompt. + */ + @JsonIgnore + public Optional speaker() { + return speaker; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The voice of the speaker. + */ + public SpeechConfig withVoice(String voice) { + Utils.checkNotNull(voice, "voice"); + this.voice = Optional.ofNullable(voice); + return this; + } + + + /** + * The voice of the speaker. + */ + public SpeechConfig withVoice(Optional voice) { + Utils.checkNotNull(voice, "voice"); + this.voice = voice; + return this; + } + + /** + * The language of the speech. + */ + public SpeechConfig withLanguage(String language) { + Utils.checkNotNull(language, "language"); + this.language = Optional.ofNullable(language); + return this; + } + + + /** + * The language of the speech. + */ + public SpeechConfig withLanguage(Optional language) { + Utils.checkNotNull(language, "language"); + this.language = language; + return this; + } + + /** + * The speaker's name, it should match the speaker name given in the prompt. + */ + public SpeechConfig withSpeaker(String speaker) { + Utils.checkNotNull(speaker, "speaker"); + this.speaker = Optional.ofNullable(speaker); + return this; + } + + + /** + * The speaker's name, it should match the speaker name given in the prompt. + */ + public SpeechConfig withSpeaker(Optional speaker) { + Utils.checkNotNull(speaker, "speaker"); + this.speaker = speaker; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpeechConfig other = (SpeechConfig) o; + return + Utils.enhancedDeepEquals(this.voice, other.voice) && + Utils.enhancedDeepEquals(this.language, other.language) && + Utils.enhancedDeepEquals(this.speaker, other.speaker); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + voice, language, speaker); + } + + @Override + public String toString() { + return Utils.toString(SpeechConfig.class, + "voice", voice, + "language", language, + "speaker", speaker); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional voice = Optional.empty(); + + private Optional language = Optional.empty(); + + private Optional speaker = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The voice of the speaker. + */ + public Builder voice(String voice) { + Utils.checkNotNull(voice, "voice"); + this.voice = Optional.ofNullable(voice); + return this; + } + + /** + * The voice of the speaker. + */ + public Builder voice(Optional voice) { + Utils.checkNotNull(voice, "voice"); + this.voice = voice; + return this; + } + + + /** + * The language of the speech. + */ + public Builder language(String language) { + Utils.checkNotNull(language, "language"); + this.language = Optional.ofNullable(language); + return this; + } + + /** + * The language of the speech. + */ + public Builder language(Optional language) { + Utils.checkNotNull(language, "language"); + this.language = language; + return this; + } + + + /** + * The speaker's name, it should match the speaker name given in the prompt. + */ + public Builder speaker(String speaker) { + Utils.checkNotNull(speaker, "speaker"); + this.speaker = Optional.ofNullable(speaker); + return this; + } + + /** + * The speaker's name, it should match the speaker name given in the prompt. + */ + public Builder speaker(Optional speaker) { + Utils.checkNotNull(speaker, "speaker"); + this.speaker = speaker; + return this; + } + + public SpeechConfig build() { + + return new SpeechConfig( + voice, language, speaker); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Status.java b/src/main/java/com/google/genai/gaos/models/interactions/Status.java new file mode 100644 index 00000000000..a1be02dccfa --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Status.java @@ -0,0 +1,299 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * Status + * + *

The `Status` type defines a logical error model that is suitable for + * different programming environments, including REST APIs and RPC APIs. It is + * used by [gRPC](https://github.com/grpc). Each `Status` message contains + * three pieces of data: error code, error message, and error details. + * + *

You can find out more about this error model and how to work with it in the + * [API Design Guide](https://cloud.google.com/apis/design/errors). + */ +@SuppressWarnings("all") +public class Status { + /** + * The status code, which should be an enum value of google.rpc.Code. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("code") + private Optional code; + + /** + * A developer-facing error message, which should be in English. Any + * user-facing error message should be localized and sent in the + * google.rpc.Status.details field, or localized by the client. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("message") + private Optional message; + + /** + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("details") + private Optional>> details; + + @JsonCreator + public Status( + @JsonProperty("code") Optional code, + @JsonProperty("message") Optional message, + @JsonProperty("details") Optional>> details) { + Utils.checkNotNull(code, "code"); + Utils.checkNotNull(message, "message"); + Utils.checkNotNull(details, "details"); + this.code = code; + this.message = message; + this.details = details; + } + + public Status() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * The status code, which should be an enum value of google.rpc.Code. + */ + @JsonIgnore + public Optional code() { + return code; + } + + /** + * A developer-facing error message, which should be in English. Any + * user-facing error message should be localized and sent in the + * google.rpc.Status.details field, or localized by the client. + */ + @JsonIgnore + public Optional message() { + return message; + } + + /** + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional>> details() { + return (Optional>>) details; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The status code, which should be an enum value of google.rpc.Code. + */ + public Status withCode(int code) { + Utils.checkNotNull(code, "code"); + this.code = Optional.ofNullable(code); + return this; + } + + + /** + * The status code, which should be an enum value of google.rpc.Code. + */ + public Status withCode(Optional code) { + Utils.checkNotNull(code, "code"); + this.code = code; + return this; + } + + /** + * A developer-facing error message, which should be in English. Any + * user-facing error message should be localized and sent in the + * google.rpc.Status.details field, or localized by the client. + */ + public Status withMessage(String message) { + Utils.checkNotNull(message, "message"); + this.message = Optional.ofNullable(message); + return this; + } + + + /** + * A developer-facing error message, which should be in English. Any + * user-facing error message should be localized and sent in the + * google.rpc.Status.details field, or localized by the client. + */ + public Status withMessage(Optional message) { + Utils.checkNotNull(message, "message"); + this.message = message; + return this; + } + + /** + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. + */ + public Status withDetails(List> details) { + Utils.checkNotNull(details, "details"); + this.details = Optional.ofNullable(details); + return this; + } + + + /** + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. + */ + public Status withDetails(Optional>> details) { + Utils.checkNotNull(details, "details"); + this.details = details; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Status other = (Status) o; + return + Utils.enhancedDeepEquals(this.code, other.code) && + Utils.enhancedDeepEquals(this.message, other.message) && + Utils.enhancedDeepEquals(this.details, other.details); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + code, message, details); + } + + @Override + public String toString() { + return Utils.toString(Status.class, + "code", code, + "message", message, + "details", details); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional code = Optional.empty(); + + private Optional message = Optional.empty(); + + private Optional>> details = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The status code, which should be an enum value of google.rpc.Code. + */ + public Builder code(int code) { + Utils.checkNotNull(code, "code"); + this.code = Optional.ofNullable(code); + return this; + } + + /** + * The status code, which should be an enum value of google.rpc.Code. + */ + public Builder code(Optional code) { + Utils.checkNotNull(code, "code"); + this.code = code; + return this; + } + + + /** + * A developer-facing error message, which should be in English. Any + * user-facing error message should be localized and sent in the + * google.rpc.Status.details field, or localized by the client. + */ + public Builder message(String message) { + Utils.checkNotNull(message, "message"); + this.message = Optional.ofNullable(message); + return this; + } + + /** + * A developer-facing error message, which should be in English. Any + * user-facing error message should be localized and sent in the + * google.rpc.Status.details field, or localized by the client. + */ + public Builder message(Optional message) { + Utils.checkNotNull(message, "message"); + this.message = message; + return this; + } + + + /** + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. + */ + public Builder details(List> details) { + Utils.checkNotNull(details, "details"); + this.details = Optional.ofNullable(details); + return this; + } + + /** + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. + */ + public Builder details(Optional>> details) { + Utils.checkNotNull(details, "details"); + this.details = details; + return this; + } + + public Status build() { + + return new Status( + code, message, details); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Step.java b/src/main/java/com/google/genai/gaos/models/interactions/Step.java new file mode 100644 index 00000000000..459b87d3759 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Step.java @@ -0,0 +1,221 @@ +/* +* 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.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; + +/** + * Step + * + *

A step in the interaction. + */ +@JsonDeserialize(using = Step._Deserializer.class) +@SuppressWarnings("all") +public class Step { + + @JsonValue + private final TypedObject value; + + private Step(TypedObject value) { + this.value = value; + } + + public static Step of(UserInputStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(ModelOutputStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(ThoughtStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(FunctionCallStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(CodeExecutionCallStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(URLContextCallStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(MCPServerToolCallStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(GoogleSearchCallStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(FileSearchCallStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(GoogleMapsCallStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(FunctionResultStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(CodeExecutionResultStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(URLContextResultStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(GoogleSearchResultStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(MCPServerToolResultStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(FileSearchResultStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Step of(GoogleMapsResultStep value) { + Utils.checkNotNull(value, "value"); + return new Step(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.UserInputStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ModelOutputStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ThoughtStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FunctionCallStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.CodeExecutionCallStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.URLContextCallStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.MCPServerToolCallStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleSearchCallStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FileSearchCallStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleMapsCallStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FunctionResultStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.CodeExecutionResultStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.URLContextResultStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleSearchResultStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.MCPServerToolResultStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FileSearchResultStep}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleMapsResultStep}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Step other = (Step) 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(Step.class, false, + 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), + 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), + 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), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(Step.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/StepDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/StepDelta.java new file mode 100644 index 00000000000..e26c34ada03 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/StepDelta.java @@ -0,0 +1,297 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class StepDelta { + + @JsonProperty("event_type") + private String eventType; + + + @JsonProperty("index") + private int index; + + + @JsonProperty("delta") + private StepDeltaData delta; + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("event_id") + private Optional eventId; + + /** + * Optional metadata accompanying ANY streamed event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata") + private Optional metadata; + + @JsonCreator + public StepDelta( + @JsonProperty("index") int index, + @JsonProperty("delta") StepDeltaData delta, + @JsonProperty("event_id") Optional eventId, + @JsonProperty("metadata") Optional metadata) { + Utils.checkNotNull(index, "index"); + Utils.checkNotNull(delta, "delta"); + Utils.checkNotNull(eventId, "eventId"); + Utils.checkNotNull(metadata, "metadata"); + this.eventType = Builder._SINGLETON_VALUE_EventType.value(); + this.index = index; + this.delta = delta; + this.eventId = eventId; + this.metadata = metadata; + } + + public StepDelta( + int index, + StepDeltaData delta) { + this(index, delta, Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String eventType() { + return eventType; + } + + @JsonIgnore + public int index() { + return index; + } + + @JsonIgnore + public StepDeltaData delta() { + return delta; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonIgnore + public Optional eventId() { + return eventId; + } + + /** + * Optional metadata accompanying ANY streamed event. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional metadata() { + return (Optional) metadata; + } + + public static Builder builder() { + return new Builder(); + } + + + public StepDelta withIndex(int index) { + Utils.checkNotNull(index, "index"); + this.index = index; + return this; + } + + public StepDelta withDelta(StepDeltaData delta) { + Utils.checkNotNull(delta, "delta"); + this.delta = delta; + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public StepDelta withEventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public StepDelta withEventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + /** + * Optional metadata accompanying ANY streamed event. + */ + public StepDelta withMetadata(StepDeltaMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + + /** + * Optional metadata accompanying ANY streamed event. + */ + public StepDelta withMetadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StepDelta other = (StepDelta) o; + return + Utils.enhancedDeepEquals(this.eventType, other.eventType) && + Utils.enhancedDeepEquals(this.index, other.index) && + Utils.enhancedDeepEquals(this.delta, other.delta) && + Utils.enhancedDeepEquals(this.eventId, other.eventId) && + Utils.enhancedDeepEquals(this.metadata, other.metadata); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + eventType, index, delta, + eventId, metadata); + } + + @Override + public String toString() { + return Utils.toString(StepDelta.class, + "eventType", eventType, + "index", index, + "delta", delta, + "eventId", eventId, + "metadata", metadata); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Integer index; + + private StepDeltaData delta; + + private Optional eventId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder index(int index) { + Utils.checkNotNull(index, "index"); + this.index = index; + return this; + } + + + public Builder delta(StepDeltaData delta) { + Utils.checkNotNull(delta, "delta"); + this.delta = delta; + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + + /** + * Optional metadata accompanying ANY streamed event. + */ + public Builder metadata(StepDeltaMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + /** + * Optional metadata accompanying ANY streamed event. + */ + public Builder metadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + public StepDelta build() { + + return new StepDelta( + index, delta, eventId, + metadata); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_EventType = + new LazySingletonValue<>( + "event_type", + "\"step.delta\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/StepDeltaData.java b/src/main/java/com/google/genai/gaos/models/interactions/StepDeltaData.java new file mode 100644 index 00000000000..a76bb2426d9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/StepDeltaData.java @@ -0,0 +1,251 @@ +/* +* 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.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; + +@JsonDeserialize(using = StepDeltaData._Deserializer.class) +@SuppressWarnings("all") +public class StepDeltaData { + + @JsonValue + private final TypedObject value; + + private StepDeltaData(TypedObject value) { + this.value = value; + } + + public static StepDeltaData of(TextDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(ImageDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(AudioDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(DocumentDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(VideoDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(ThoughtSummaryDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(ThoughtSignatureDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(TextAnnotationDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(ArgumentsDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(CodeExecutionCallDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(URLContextCallDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(GoogleSearchCallDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(MCPServerToolCallDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(FileSearchCallDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(GoogleMapsCallDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(CodeExecutionResultDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(URLContextResultDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(GoogleSearchResultDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(MCPServerToolResultDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(FileSearchResultDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(GoogleMapsResultDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static StepDeltaData of(FunctionResultDelta value) { + Utils.checkNotNull(value, "value"); + return new StepDeltaData(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *
    + *
  • {@code com.google.genai.gaos.models.interactions.TextDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ImageDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.AudioDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.DocumentDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.VideoDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ThoughtSummaryDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ThoughtSignatureDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.TextAnnotationDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ArgumentsDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.CodeExecutionCallDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.URLContextCallDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleSearchCallDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.MCPServerToolCallDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FileSearchCallDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleMapsCallDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.CodeExecutionResultDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.URLContextResultDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleSearchResultDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.MCPServerToolResultDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FileSearchResultDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleMapsResultDelta}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FunctionResultDelta}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StepDeltaData other = (StepDeltaData) 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(StepDeltaData.class, false, + 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), + 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), + 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), + 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), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(StepDeltaData.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/StepDeltaMetadata.java b/src/main/java/com/google/genai/gaos/models/interactions/StepDeltaMetadata.java new file mode 100644 index 00000000000..3b2ba176153 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/StepDeltaMetadata.java @@ -0,0 +1,151 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * StepDeltaMetadata + * + *

Optional metadata accompanying ANY streamed event. + */ +@SuppressWarnings("all") +public class StepDeltaMetadata { + /** + * Statistics on the interaction request's token usage. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("total_usage") + private Optional totalUsage; + + @JsonCreator + public StepDeltaMetadata( + @JsonProperty("total_usage") Optional totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = totalUsage; + } + + public StepDeltaMetadata() { + this(Optional.empty()); + } + + /** + * Statistics on the interaction request's token usage. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional totalUsage() { + return (Optional) totalUsage; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Statistics on the interaction request's token usage. + */ + public StepDeltaMetadata withTotalUsage(Usage totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = Optional.ofNullable(totalUsage); + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public StepDeltaMetadata withTotalUsage(Optional totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = totalUsage; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StepDeltaMetadata other = (StepDeltaMetadata) o; + return + Utils.enhancedDeepEquals(this.totalUsage, other.totalUsage); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + totalUsage); + } + + @Override + public String toString() { + return Utils.toString(StepDeltaMetadata.class, + "totalUsage", totalUsage); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional totalUsage = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Statistics on the interaction request's token usage. + */ + public Builder totalUsage(Usage totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = Optional.ofNullable(totalUsage); + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Builder totalUsage(Optional totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = totalUsage; + return this; + } + + public StepDeltaMetadata build() { + + return new StepDeltaMetadata( + totalUsage); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/StepStart.java b/src/main/java/com/google/genai/gaos/models/interactions/StepStart.java new file mode 100644 index 00000000000..93d65a2c02c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/StepStart.java @@ -0,0 +1,291 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class StepStart { + + @JsonProperty("event_type") + private String eventType; + + + @JsonProperty("index") + private int index; + + /** + * A step in the interaction. + */ + @JsonProperty("step") + private Step step; + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("event_id") + private Optional eventId; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata") + private Optional metadata; + + @JsonCreator + public StepStart( + @JsonProperty("index") int index, + @JsonProperty("step") Step step, + @JsonProperty("event_id") Optional eventId, + @JsonProperty("metadata") Optional metadata) { + Utils.checkNotNull(index, "index"); + Utils.checkNotNull(step, "step"); + Utils.checkNotNull(eventId, "eventId"); + Utils.checkNotNull(metadata, "metadata"); + this.eventType = Builder._SINGLETON_VALUE_EventType.value(); + this.index = index; + this.step = step; + this.eventId = eventId; + this.metadata = metadata; + } + + public StepStart( + int index, + Step step) { + this(index, step, Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String eventType() { + return eventType; + } + + @JsonIgnore + public int index() { + return index; + } + + /** + * A step in the interaction. + */ + @JsonIgnore + public Step step() { + return step; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonIgnore + public Optional eventId() { + return eventId; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional metadata() { + return (Optional) metadata; + } + + public static Builder builder() { + return new Builder(); + } + + + public StepStart withIndex(int index) { + Utils.checkNotNull(index, "index"); + this.index = index; + return this; + } + + /** + * A step in the interaction. + */ + public StepStart withStep(Step step) { + Utils.checkNotNull(step, "step"); + this.step = step; + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public StepStart withEventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public StepStart withEventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + public StepStart withMetadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + + public StepStart withMetadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StepStart other = (StepStart) o; + return + Utils.enhancedDeepEquals(this.eventType, other.eventType) && + Utils.enhancedDeepEquals(this.index, other.index) && + Utils.enhancedDeepEquals(this.step, other.step) && + Utils.enhancedDeepEquals(this.eventId, other.eventId) && + Utils.enhancedDeepEquals(this.metadata, other.metadata); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + eventType, index, step, + eventId, metadata); + } + + @Override + public String toString() { + return Utils.toString(StepStart.class, + "eventType", eventType, + "index", index, + "step", step, + "eventId", eventId, + "metadata", metadata); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Integer index; + + private Step step; + + private Optional eventId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder index(int index) { + Utils.checkNotNull(index, "index"); + this.index = index; + return this; + } + + + /** + * A step in the interaction. + */ + public Builder step(Step step) { + Utils.checkNotNull(step, "step"); + this.step = step; + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + + public Builder metadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public Builder metadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + public StepStart build() { + + return new StepStart( + index, step, eventId, + metadata); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_EventType = + new LazySingletonValue<>( + "event_type", + "\"step.start\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/StepStop.java b/src/main/java/com/google/genai/gaos/models/interactions/StepStop.java new file mode 100644 index 00000000000..991ee5cd2b4 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/StepStop.java @@ -0,0 +1,372 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class StepStop { + + @JsonProperty("event_type") + private String eventType; + + + @JsonProperty("index") + private int index; + + /** + * Statistics on the interaction request's token usage. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("usage") + private Optional usage; + + /** + * Statistics on the interaction request's token usage. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("step_usage") + private Optional stepUsage; + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("event_id") + private Optional eventId; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("metadata") + private Optional metadata; + + @JsonCreator + public StepStop( + @JsonProperty("index") int index, + @JsonProperty("usage") Optional usage, + @JsonProperty("step_usage") Optional stepUsage, + @JsonProperty("event_id") Optional eventId, + @JsonProperty("metadata") Optional metadata) { + Utils.checkNotNull(index, "index"); + Utils.checkNotNull(usage, "usage"); + Utils.checkNotNull(stepUsage, "stepUsage"); + Utils.checkNotNull(eventId, "eventId"); + Utils.checkNotNull(metadata, "metadata"); + this.eventType = Builder._SINGLETON_VALUE_EventType.value(); + this.index = index; + this.usage = usage; + this.stepUsage = stepUsage; + this.eventId = eventId; + this.metadata = metadata; + } + + public StepStop( + int index) { + this(index, Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String eventType() { + return eventType; + } + + @JsonIgnore + public int index() { + return index; + } + + /** + * Statistics on the interaction request's token usage. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional usage() { + return (Optional) usage; + } + + /** + * Statistics on the interaction request's token usage. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional stepUsage() { + return (Optional) stepUsage; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + @JsonIgnore + public Optional eventId() { + return eventId; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional metadata() { + return (Optional) metadata; + } + + public static Builder builder() { + return new Builder(); + } + + + public StepStop withIndex(int index) { + Utils.checkNotNull(index, "index"); + this.index = index; + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public StepStop withUsage(Usage usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = Optional.ofNullable(usage); + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public StepStop withUsage(Optional usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = usage; + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public StepStop withStepUsage(Usage stepUsage) { + Utils.checkNotNull(stepUsage, "stepUsage"); + this.stepUsage = Optional.ofNullable(stepUsage); + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public StepStop withStepUsage(Optional stepUsage) { + Utils.checkNotNull(stepUsage, "stepUsage"); + this.stepUsage = stepUsage; + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public StepStop withEventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public StepStop withEventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + public StepStop withMetadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + + public StepStop withMetadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StepStop other = (StepStop) o; + return + Utils.enhancedDeepEquals(this.eventType, other.eventType) && + Utils.enhancedDeepEquals(this.index, other.index) && + Utils.enhancedDeepEquals(this.usage, other.usage) && + Utils.enhancedDeepEquals(this.stepUsage, other.stepUsage) && + Utils.enhancedDeepEquals(this.eventId, other.eventId) && + Utils.enhancedDeepEquals(this.metadata, other.metadata); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + eventType, index, usage, + stepUsage, eventId, metadata); + } + + @Override + public String toString() { + return Utils.toString(StepStop.class, + "eventType", eventType, + "index", index, + "usage", usage, + "stepUsage", stepUsage, + "eventId", eventId, + "metadata", metadata); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Integer index; + + private Optional usage = Optional.empty(); + + private Optional stepUsage = Optional.empty(); + + private Optional eventId = Optional.empty(); + + private Optional metadata = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder index(int index) { + Utils.checkNotNull(index, "index"); + this.index = index; + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public Builder usage(Usage usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = Optional.ofNullable(usage); + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Builder usage(Optional usage) { + Utils.checkNotNull(usage, "usage"); + this.usage = usage; + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public Builder stepUsage(Usage stepUsage) { + Utils.checkNotNull(stepUsage, "stepUsage"); + this.stepUsage = Optional.ofNullable(stepUsage); + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Builder stepUsage(Optional stepUsage) { + Utils.checkNotNull(stepUsage, "stepUsage"); + this.stepUsage = stepUsage; + return this; + } + + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(String eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = Optional.ofNullable(eventId); + return this; + } + + /** + * The event_id token to be used to resume the interaction stream, from + * this event. + */ + public Builder eventId(Optional eventId) { + Utils.checkNotNull(eventId, "eventId"); + this.eventId = eventId; + return this; + } + + + public Builder metadata(StreamMetadata metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = Optional.ofNullable(metadata); + return this; + } + + public Builder metadata(Optional metadata) { + Utils.checkNotNull(metadata, "metadata"); + this.metadata = metadata; + return this; + } + + public StepStop build() { + + return new StepStop( + index, usage, stepUsage, + eventId, metadata); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_EventType = + new LazySingletonValue<>( + "event_type", + "\"step.stop\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/StreamMetadata.java b/src/main/java/com/google/genai/gaos/models/interactions/StreamMetadata.java new file mode 100644 index 00000000000..66db12d365e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/StreamMetadata.java @@ -0,0 +1,147 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class StreamMetadata { + /** + * Statistics on the interaction request's token usage. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("total_usage") + private Optional totalUsage; + + @JsonCreator + public StreamMetadata( + @JsonProperty("total_usage") Optional totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = totalUsage; + } + + public StreamMetadata() { + this(Optional.empty()); + } + + /** + * Statistics on the interaction request's token usage. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional totalUsage() { + return (Optional) totalUsage; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Statistics on the interaction request's token usage. + */ + public StreamMetadata withTotalUsage(Usage totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = Optional.ofNullable(totalUsage); + return this; + } + + + /** + * Statistics on the interaction request's token usage. + */ + public StreamMetadata withTotalUsage(Optional totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = totalUsage; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StreamMetadata other = (StreamMetadata) o; + return + Utils.enhancedDeepEquals(this.totalUsage, other.totalUsage); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + totalUsage); + } + + @Override + public String toString() { + return Utils.toString(StreamMetadata.class, + "totalUsage", totalUsage); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional totalUsage = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Statistics on the interaction request's token usage. + */ + public Builder totalUsage(Usage totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = Optional.ofNullable(totalUsage); + return this; + } + + /** + * Statistics on the interaction request's token usage. + */ + public Builder totalUsage(Optional totalUsage) { + Utils.checkNotNull(totalUsage, "totalUsage"); + this.totalUsage = totalUsage; + return this; + } + + public StreamMetadata build() { + + return new StreamMetadata( + totalUsage); + } + + } +} 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 new file mode 100644 index 00000000000..40b299b5caf --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Task.java @@ -0,0 +1,61 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * Task + * + *

Optional task mode for video generation. If not specified, the model + * automatically determines the appropriate mode based on the provided text + * prompt and input media. + */ +@SuppressWarnings("all") +public enum Task { + TEXT_TO_VIDEO("text_to_video"), + IMAGE_TO_VIDEO("image_to_video"), + REFERENCE_TO_VIDEO("reference_to_video"), + EDIT("edit"); + + @JsonValue + private final String value; + + Task(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (Task o: Task.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TextAnnotationDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/TextAnnotationDelta.java new file mode 100644 index 00000000000..e7e5f74e534 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/TextAnnotationDelta.java @@ -0,0 +1,168 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + + +@SuppressWarnings("all") +public class TextAnnotationDelta { + + @JsonProperty("type") + private String type; + + /** + * Citation information for model-generated content. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("annotations") + private Optional> annotations; + + @JsonCreator + public TextAnnotationDelta( + @JsonProperty("annotations") Optional> annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.annotations = annotations; + } + + public TextAnnotationDelta() { + this(Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Citation information for model-generated content. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> annotations() { + return (Optional>) annotations; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Citation information for model-generated content. + */ + public TextAnnotationDelta withAnnotations(List annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.annotations = Optional.ofNullable(annotations); + return this; + } + + + /** + * Citation information for model-generated content. + */ + public TextAnnotationDelta withAnnotations(Optional> annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.annotations = annotations; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TextAnnotationDelta other = (TextAnnotationDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.annotations, other.annotations); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, annotations); + } + + @Override + public String toString() { + return Utils.toString(TextAnnotationDelta.class, + "type", type, + "annotations", annotations); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> annotations = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Citation information for model-generated content. + */ + public Builder annotations(List annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.annotations = Optional.ofNullable(annotations); + return this; + } + + /** + * Citation information for model-generated content. + */ + public Builder annotations(Optional> annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.annotations = annotations; + return this; + } + + public TextAnnotationDelta build() { + + return new TextAnnotationDelta( + annotations); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"text_annotation_delta\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TextContent.java b/src/main/java/com/google/genai/gaos/models/interactions/TextContent.java new file mode 100644 index 00000000000..57ccce210b4 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/TextContent.java @@ -0,0 +1,213 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * TextContent + * + *

A text content block. + */ +@SuppressWarnings("all") +public class TextContent { + + @JsonProperty("type") + private String type; + + /** + * Required. The text content. + */ + @JsonProperty("text") + private String text; + + /** + * Citation information for model-generated content. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("annotations") + private Optional> annotations; + + @JsonCreator + public TextContent( + @JsonProperty("text") String text, + @JsonProperty("annotations") Optional> annotations) { + Utils.checkNotNull(text, "text"); + Utils.checkNotNull(annotations, "annotations"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.text = text; + this.annotations = annotations; + } + + public TextContent( + String text) { + this(text, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. The text content. + */ + @JsonIgnore + public String text() { + return text; + } + + /** + * Citation information for model-generated content. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> annotations() { + return (Optional>) annotations; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. The text content. + */ + public TextContent withText(String text) { + Utils.checkNotNull(text, "text"); + this.text = text; + return this; + } + + /** + * Citation information for model-generated content. + */ + public TextContent withAnnotations(List annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.annotations = Optional.ofNullable(annotations); + return this; + } + + + /** + * Citation information for model-generated content. + */ + public TextContent withAnnotations(Optional> annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.annotations = annotations; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TextContent other = (TextContent) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.text, other.text) && + Utils.enhancedDeepEquals(this.annotations, other.annotations); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, text, annotations); + } + + @Override + public String toString() { + return Utils.toString(TextContent.class, + "type", type, + "text", text, + "annotations", annotations); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String text; + + private Optional> annotations = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. The text content. + */ + public Builder text(String text) { + Utils.checkNotNull(text, "text"); + this.text = text; + return this; + } + + + /** + * Citation information for model-generated content. + */ + public Builder annotations(List annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.annotations = Optional.ofNullable(annotations); + return this; + } + + /** + * Citation information for model-generated content. + */ + public Builder annotations(Optional> annotations) { + Utils.checkNotNull(annotations, "annotations"); + this.annotations = annotations; + return this; + } + + public TextContent build() { + + return new TextContent( + text, annotations); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"text\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TextDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/TextDelta.java new file mode 100644 index 00000000000..23190edc485 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/TextDelta.java @@ -0,0 +1,127 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; + + +@SuppressWarnings("all") +public class TextDelta { + + @JsonProperty("type") + private String type; + + + @JsonProperty("text") + private String text; + + @JsonCreator + public TextDelta( + @JsonProperty("text") String text) { + Utils.checkNotNull(text, "text"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.text = text; + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public String text() { + return text; + } + + public static Builder builder() { + return new Builder(); + } + + + public TextDelta withText(String text) { + Utils.checkNotNull(text, "text"); + this.text = text; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TextDelta other = (TextDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.text, other.text); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, text); + } + + @Override + public String toString() { + return Utils.toString(TextDelta.class, + "type", type, + "text", text); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String text; + + private Builder() { + // force use of static builder() method + } + + + public Builder text(String text) { + Utils.checkNotNull(text, "text"); + this.text = text; + return this; + } + + public TextDelta build() { + + return new TextDelta( + text); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"text\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TextResponseFormat.java b/src/main/java/com/google/genai/gaos/models/interactions/TextResponseFormat.java new file mode 100644 index 00000000000..99cee5bbed1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/TextResponseFormat.java @@ -0,0 +1,240 @@ +/* +* 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.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Map; +import java.util.Optional; + +/** + * TextResponseFormat + * + *

Configuration for text output format. + */ +@SuppressWarnings("all") +public class TextResponseFormat { + + @JsonProperty("type") + private String type; + + /** + * The MIME type of the text output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + /** + * The JSON schema that the output should conform to. Only applicable when + * mime_type is application/json. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("schema") + private Optional> schema; + + @JsonCreator + public TextResponseFormat( + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("schema") Optional> schema) { + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(schema, "schema"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.mimeType = mimeType; + this.schema = schema; + } + + public TextResponseFormat() { + this(Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The MIME type of the text output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + /** + * The JSON schema that the output should conform to. Only applicable when + * mime_type is application/json. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> schema() { + return (Optional>) schema; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The MIME type of the text output. + */ + public TextResponseFormat withMimeType(TextResponseFormatMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + /** + * The MIME type of the text output. + */ + public TextResponseFormat withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + /** + * The JSON schema that the output should conform to. Only applicable when + * mime_type is application/json. + */ + public TextResponseFormat withSchema(Map schema) { + Utils.checkNotNull(schema, "schema"); + this.schema = Optional.ofNullable(schema); + return this; + } + + + /** + * The JSON schema that the output should conform to. Only applicable when + * mime_type is application/json. + */ + public TextResponseFormat withSchema(Optional> schema) { + Utils.checkNotNull(schema, "schema"); + this.schema = schema; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TextResponseFormat other = (TextResponseFormat) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.schema, other.schema); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, mimeType, schema); + } + + @Override + public String toString() { + return Utils.toString(TextResponseFormat.class, + "type", type, + "mimeType", mimeType, + "schema", schema); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional mimeType = Optional.empty(); + + private Optional> schema = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The MIME type of the text output. + */ + public Builder mimeType(TextResponseFormatMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + /** + * The MIME type of the text output. + */ + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + /** + * The JSON schema that the output should conform to. Only applicable when + * mime_type is application/json. + */ + public Builder schema(Map schema) { + Utils.checkNotNull(schema, "schema"); + this.schema = Optional.ofNullable(schema); + return this; + } + + /** + * The JSON schema that the output should conform to. Only applicable when + * mime_type is application/json. + */ + public Builder schema(Optional> schema) { + Utils.checkNotNull(schema, "schema"); + this.schema = schema; + return this; + } + + public TextResponseFormat build() { + + return new TextResponseFormat( + mimeType, schema); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"text\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TextResponseFormatMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/TextResponseFormatMimeType.java new file mode 100644 index 00000000000..b4314071df4 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/TextResponseFormatMimeType.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * TextResponseFormatMimeType + * + *

The MIME type of the text output. + */ +@SuppressWarnings("all") +public enum TextResponseFormatMimeType { + APPLICATION_JSON("application/json"), + TEXT_PLAIN("text/plain"); + + @JsonValue + private final String value; + + TextResponseFormatMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (TextResponseFormatMimeType o: TextResponseFormatMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ThinkingLevel.java b/src/main/java/com/google/genai/gaos/models/interactions/ThinkingLevel.java new file mode 100644 index 00000000000..02ca641ca68 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ThinkingLevel.java @@ -0,0 +1,54 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum ThinkingLevel { + MINIMAL("minimal"), + LOW("low"), + MEDIUM("medium"), + HIGH("high"); + + @JsonValue + private final String value; + + ThinkingLevel(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ThinkingLevel o: ThinkingLevel.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ThinkingSummaries.java b/src/main/java/com/google/genai/gaos/models/interactions/ThinkingSummaries.java new file mode 100644 index 00000000000..f14a4483f3d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ThinkingSummaries.java @@ -0,0 +1,52 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum ThinkingSummaries { + AUTO("auto"), + NONE("none"); + + @JsonValue + private final String value; + + ThinkingSummaries(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ThinkingSummaries o: ThinkingSummaries.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSignatureDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSignatureDelta.java new file mode 100644 index 00000000000..3de7b249dbc --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSignatureDelta.java @@ -0,0 +1,165 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ThoughtSignatureDelta { + + @JsonProperty("type") + private String type; + + /** + * Signature to match the backend source to be part of the generation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public ThoughtSignatureDelta( + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.signature = signature; + } + + public ThoughtSignatureDelta() { + this(Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Signature to match the backend source to be part of the generation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Signature to match the backend source to be part of the generation. + */ + public ThoughtSignatureDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * Signature to match the backend source to be part of the generation. + */ + public ThoughtSignatureDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThoughtSignatureDelta other = (ThoughtSignatureDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, signature); + } + + @Override + public String toString() { + return Utils.toString(ThoughtSignatureDelta.class, + "type", type, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Signature to match the backend source to be part of the generation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * Signature to match the backend source to be part of the generation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public ThoughtSignatureDelta build() { + + return new ThoughtSignatureDelta( + signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"thought_signature\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ThoughtStep.java b/src/main/java/com/google/genai/gaos/models/interactions/ThoughtStep.java new file mode 100644 index 00000000000..7b67efff2da --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ThoughtStep.java @@ -0,0 +1,232 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * ThoughtStep + * + *

A thought step. + */ +@SuppressWarnings("all") +public class ThoughtStep { + + @JsonProperty("type") + private String type; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + /** + * A summary of the thought. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("summary") + private Optional> summary; + + @JsonCreator + public ThoughtStep( + @JsonProperty("signature") Optional signature, + @JsonProperty("summary") Optional> summary) { + Utils.checkNotNull(signature, "signature"); + Utils.checkNotNull(summary, "summary"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.signature = signature; + this.summary = summary; + } + + public ThoughtStep() { + this(Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + /** + * A summary of the thought. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> summary() { + return (Optional>) summary; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * A signature hash for backend validation. + */ + public ThoughtStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public ThoughtStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + /** + * A summary of the thought. + */ + public ThoughtStep withSummary(List summary) { + Utils.checkNotNull(summary, "summary"); + this.summary = Optional.ofNullable(summary); + return this; + } + + + /** + * A summary of the thought. + */ + public ThoughtStep withSummary(Optional> summary) { + Utils.checkNotNull(summary, "summary"); + this.summary = summary; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThoughtStep other = (ThoughtStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.signature, other.signature) && + Utils.enhancedDeepEquals(this.summary, other.summary); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, signature, summary); + } + + @Override + public String toString() { + return Utils.toString(ThoughtStep.class, + "type", type, + "signature", signature, + "summary", summary); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional signature = Optional.empty(); + + private Optional> summary = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + + /** + * A summary of the thought. + */ + public Builder summary(List summary) { + Utils.checkNotNull(summary, "summary"); + this.summary = Optional.ofNullable(summary); + return this; + } + + /** + * A summary of the thought. + */ + public Builder summary(Optional> summary) { + Utils.checkNotNull(summary, "summary"); + this.summary = summary; + return this; + } + + public ThoughtStep build() { + + return new ThoughtStep( + signature, summary); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"thought\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSummaryContent.java b/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSummaryContent.java new file mode 100644 index 00000000000..bb965b5e7fe --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSummaryContent.java @@ -0,0 +1,111 @@ +/* +* 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.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; + +@JsonDeserialize(using = ThoughtSummaryContent._Deserializer.class) +@SuppressWarnings("all") +public class ThoughtSummaryContent { + + @JsonValue + private final TypedObject value; + + private ThoughtSummaryContent(TypedObject value) { + this.value = value; + } + + public static ThoughtSummaryContent of(TextContent value) { + Utils.checkNotNull(value, "value"); + return new ThoughtSummaryContent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static ThoughtSummaryContent of(ImageContent value) { + Utils.checkNotNull(value, "value"); + return new ThoughtSummaryContent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.TextContent}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ImageContent}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThoughtSummaryContent other = (ThoughtSummaryContent) 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(ThoughtSummaryContent.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(ThoughtSummaryContent.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSummaryDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSummaryDelta.java new file mode 100644 index 00000000000..9bfdd6df730 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ThoughtSummaryDelta.java @@ -0,0 +1,167 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ThoughtSummaryDelta { + + @JsonProperty("type") + private String type; + + /** + * The content of the response. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("content") + private Optional content; + + @JsonCreator + public ThoughtSummaryDelta( + @JsonProperty("content") Optional content) { + Utils.checkNotNull(content, "content"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.content = content; + } + + public ThoughtSummaryDelta() { + this(Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The content of the response. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional content() { + return (Optional) content; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The content of the response. + */ + public ThoughtSummaryDelta withContent(Content content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + + /** + * The content of the response. + */ + public ThoughtSummaryDelta withContent(Optional content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThoughtSummaryDelta other = (ThoughtSummaryDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.content, other.content); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, content); + } + + @Override + public String toString() { + return Utils.toString(ThoughtSummaryDelta.class, + "type", type, + "content", content); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional content = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The content of the response. + */ + public Builder content(Content content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + /** + * The content of the response. + */ + public Builder content(Optional content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + public ThoughtSummaryDelta build() { + + return new ThoughtSummaryDelta( + content); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"thought_summary\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Tool.java b/src/main/java/com/google/genai/gaos/models/interactions/Tool.java new file mode 100644 index 00000000000..192921c651f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Tool.java @@ -0,0 +1,165 @@ +/* +* 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.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; + +/** + * Tool + * + *

A tool that can be used by the model. + */ +@JsonDeserialize(using = Tool._Deserializer.class) +@SuppressWarnings("all") +public class Tool { + + @JsonValue + private final TypedObject value; + + private Tool(TypedObject value) { + this.value = value; + } + + public static Tool of(Function value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Tool of(CodeExecution value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Tool of(URLContext value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Tool of(ComputerUse value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Tool of(MCPServer value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Tool of(GoogleSearch value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Tool of(FileSearch value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Tool of(GoogleMaps value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static Tool of(Retrieval value) { + Utils.checkNotNull(value, "value"); + return new Tool(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.Function}
  • + *
  • {@code com.google.genai.gaos.models.interactions.CodeExecution}
  • + *
  • {@code com.google.genai.gaos.models.interactions.URLContext}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ComputerUse}
  • + *
  • {@code com.google.genai.gaos.models.interactions.MCPServer}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleSearch}
  • + *
  • {@code com.google.genai.gaos.models.interactions.FileSearch}
  • + *
  • {@code com.google.genai.gaos.models.interactions.GoogleMaps}
  • + *
  • {@code com.google.genai.gaos.models.interactions.Retrieval}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tool other = (Tool) 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(Tool.class, false, + 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), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(Tool.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ToolChoice.java b/src/main/java/com/google/genai/gaos/models/interactions/ToolChoice.java new file mode 100644 index 00000000000..0d031c148c6 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ToolChoice.java @@ -0,0 +1,116 @@ +/* +* 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.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; + +/** + * ToolChoice + * + *

The tool choice configuration. + */ +@JsonDeserialize(using = ToolChoice._Deserializer.class) +@SuppressWarnings("all") +public class ToolChoice { + + @JsonValue + private final TypedObject value; + + private ToolChoice(TypedObject value) { + this.value = value; + } + + public static ToolChoice of(ToolChoiceType value) { + Utils.checkNotNull(value, "value"); + return new ToolChoice(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static ToolChoice of(ToolChoiceConfig value) { + Utils.checkNotNull(value, "value"); + return new ToolChoice(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.ToolChoiceType}
  • + *
  • {@code com.google.genai.gaos.models.interactions.ToolChoiceConfig}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ToolChoice other = (ToolChoice) 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(ToolChoice.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(ToolChoice.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ToolChoiceConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/ToolChoiceConfig.java new file mode 100644 index 00000000000..c98d4a0c2eb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ToolChoiceConfig.java @@ -0,0 +1,151 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * ToolChoiceConfig + * + *

The tool choice configuration containing allowed tools. + */ +@SuppressWarnings("all") +public class ToolChoiceConfig { + /** + * The configuration for allowed tools. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("allowed_tools") + private Optional allowedTools; + + @JsonCreator + public ToolChoiceConfig( + @JsonProperty("allowed_tools") Optional allowedTools) { + Utils.checkNotNull(allowedTools, "allowedTools"); + this.allowedTools = allowedTools; + } + + public ToolChoiceConfig() { + this(Optional.empty()); + } + + /** + * The configuration for allowed tools. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional allowedTools() { + return (Optional) allowedTools; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The configuration for allowed tools. + */ + public ToolChoiceConfig withAllowedTools(AllowedTools allowedTools) { + Utils.checkNotNull(allowedTools, "allowedTools"); + this.allowedTools = Optional.ofNullable(allowedTools); + return this; + } + + + /** + * The configuration for allowed tools. + */ + public ToolChoiceConfig withAllowedTools(Optional allowedTools) { + Utils.checkNotNull(allowedTools, "allowedTools"); + this.allowedTools = allowedTools; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ToolChoiceConfig other = (ToolChoiceConfig) o; + return + Utils.enhancedDeepEquals(this.allowedTools, other.allowedTools); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + allowedTools); + } + + @Override + public String toString() { + return Utils.toString(ToolChoiceConfig.class, + "allowedTools", allowedTools); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional allowedTools = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The configuration for allowed tools. + */ + public Builder allowedTools(AllowedTools allowedTools) { + Utils.checkNotNull(allowedTools, "allowedTools"); + this.allowedTools = Optional.ofNullable(allowedTools); + return this; + } + + /** + * The configuration for allowed tools. + */ + public Builder allowedTools(Optional allowedTools) { + Utils.checkNotNull(allowedTools, "allowedTools"); + this.allowedTools = allowedTools; + return this; + } + + public ToolChoiceConfig build() { + + return new ToolChoiceConfig( + allowedTools); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ToolChoiceType.java b/src/main/java/com/google/genai/gaos/models/interactions/ToolChoiceType.java new file mode 100644 index 00000000000..922b063f850 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ToolChoiceType.java @@ -0,0 +1,54 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum ToolChoiceType { + AUTO("auto"), + ANY("any"), + NONE("none"), + VALIDATED("validated"); + + @JsonValue + private final String value; + + ToolChoiceType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (ToolChoiceType o: ToolChoiceType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + 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 new file mode 100644 index 00000000000..9bd141f61c3 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Turn.java @@ -0,0 +1,202 @@ +/* +* 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.JsonIgnore; +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 java.lang.Deprecated; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +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 +@SuppressWarnings("all") +public class Turn { + /** + * The originator of this turn. Must be user for input or model for + * model output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("role") + private Optional role; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("content") + private Optional content; + + @JsonCreator + public Turn( + @JsonProperty("role") Optional role, + @JsonProperty("content") Optional content) { + Utils.checkNotNull(role, "role"); + Utils.checkNotNull(content, "content"); + this.role = role; + this.content = content; + } + + public Turn() { + this(Optional.empty(), Optional.empty()); + } + + /** + * The originator of this turn. Must be user for input or model for + * model output. + */ + @JsonIgnore + public Optional role() { + return role; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional content() { + return (Optional) content; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The originator of this turn. Must be user for input or model for + * model output. + */ + public Turn withRole(String role) { + Utils.checkNotNull(role, "role"); + this.role = Optional.ofNullable(role); + return this; + } + + + /** + * The originator of this turn. Must be user for input or model for + * model output. + */ + public Turn withRole(Optional role) { + Utils.checkNotNull(role, "role"); + this.role = role; + return this; + } + + public Turn withContent(TurnContent content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + + public Turn withContent(Optional content) { + Utils.checkNotNull(content, "content"); + this.content = content; + 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.role, other.role) && + Utils.enhancedDeepEquals(this.content, other.content); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + role, content); + } + + @Override + public String toString() { + return Utils.toString(Turn.class, + "role", role, + "content", content); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional role = Optional.empty(); + + private Optional content = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The originator of this turn. Must be user for input or model for + * model output. + */ + public Builder role(String role) { + Utils.checkNotNull(role, "role"); + this.role = Optional.ofNullable(role); + return this; + } + + /** + * The originator of this turn. Must be user for input or model for + * model output. + */ + public Builder role(Optional role) { + Utils.checkNotNull(role, "role"); + this.role = role; + return this; + } + + + public Builder content(TurnContent content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + public Builder content(Optional content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + public Turn build() { + + return new Turn( + role, content); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TurnContent.java b/src/main/java/com/google/genai/gaos/models/interactions/TurnContent.java new file mode 100644 index 00000000000..89502781e3d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/TurnContent.java @@ -0,0 +1,112 @@ +/* +* 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.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.List; + +@JsonDeserialize(using = TurnContent._Deserializer.class) +@SuppressWarnings("all") +public class TurnContent { + + @JsonValue + private final TypedObject value; + + private TurnContent(TypedObject value) { + this.value = value; + } + + public static TurnContent of(List value) { + Utils.checkNotNull(value, "value"); + return new TurnContent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static TurnContent of(String value) { + Utils.checkNotNull(value, "value"); + return new TurnContent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code java.util.List}
  • + *
  • {@code java.lang.String}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TurnContent other = (TurnContent) 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(TurnContent.class, false, + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(TurnContent.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLCitation.java b/src/main/java/com/google/genai/gaos/models/interactions/URLCitation.java new file mode 100644 index 00000000000..3d7b97bec28 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLCitation.java @@ -0,0 +1,365 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * URLCitation + * + *

A URL citation annotation. + */ +@SuppressWarnings("all") +public class URLCitation { + + @JsonProperty("type") + private String type; + + /** + * The URL. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("url") + private Optional url; + + /** + * The title of the URL. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("title") + private Optional title; + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("start_index") + private Optional startIndex; + + /** + * End of the attributed segment, exclusive. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("end_index") + private Optional endIndex; + + @JsonCreator + public URLCitation( + @JsonProperty("url") Optional url, + @JsonProperty("title") Optional title, + @JsonProperty("start_index") Optional startIndex, + @JsonProperty("end_index") Optional endIndex) { + Utils.checkNotNull(url, "url"); + Utils.checkNotNull(title, "title"); + Utils.checkNotNull(startIndex, "startIndex"); + Utils.checkNotNull(endIndex, "endIndex"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.url = url; + this.title = title; + this.startIndex = startIndex; + this.endIndex = endIndex; + } + + public URLCitation() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The URL. + */ + @JsonIgnore + public Optional url() { + return url; + } + + /** + * The title of the URL. + */ + @JsonIgnore + public Optional title() { + return title; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + @JsonIgnore + public Optional startIndex() { + return startIndex; + } + + /** + * End of the attributed segment, exclusive. + */ + @JsonIgnore + public Optional endIndex() { + return endIndex; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The URL. + */ + public URLCitation withUrl(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + + /** + * The URL. + */ + public URLCitation withUrl(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + /** + * The title of the URL. + */ + public URLCitation withTitle(String title) { + Utils.checkNotNull(title, "title"); + this.title = Optional.ofNullable(title); + return this; + } + + + /** + * The title of the URL. + */ + public URLCitation withTitle(Optional title) { + Utils.checkNotNull(title, "title"); + this.title = title; + return this; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public URLCitation withStartIndex(int startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = Optional.ofNullable(startIndex); + return this; + } + + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public URLCitation withStartIndex(Optional startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = startIndex; + return this; + } + + /** + * End of the attributed segment, exclusive. + */ + public URLCitation withEndIndex(int endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = Optional.ofNullable(endIndex); + return this; + } + + + /** + * End of the attributed segment, exclusive. + */ + public URLCitation withEndIndex(Optional endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = endIndex; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + URLCitation other = (URLCitation) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.url, other.url) && + Utils.enhancedDeepEquals(this.title, other.title) && + Utils.enhancedDeepEquals(this.startIndex, other.startIndex) && + Utils.enhancedDeepEquals(this.endIndex, other.endIndex); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, url, title, + startIndex, endIndex); + } + + @Override + public String toString() { + return Utils.toString(URLCitation.class, + "type", type, + "url", url, + "title", title, + "startIndex", startIndex, + "endIndex", endIndex); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional url = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional startIndex = Optional.empty(); + + private Optional endIndex = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The URL. + */ + public Builder url(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + /** + * The URL. + */ + public Builder url(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + + /** + * The title of the URL. + */ + public Builder title(String title) { + Utils.checkNotNull(title, "title"); + this.title = Optional.ofNullable(title); + return this; + } + + /** + * The title of the URL. + */ + public Builder title(Optional title) { + Utils.checkNotNull(title, "title"); + this.title = title; + return this; + } + + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public Builder startIndex(int startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = Optional.ofNullable(startIndex); + return this; + } + + /** + * Start of segment of the response that is attributed to this source. + * + *

Index indicates the start of the segment, measured in bytes. + */ + public Builder startIndex(Optional startIndex) { + Utils.checkNotNull(startIndex, "startIndex"); + this.startIndex = startIndex; + return this; + } + + + /** + * End of the attributed segment, exclusive. + */ + public Builder endIndex(int endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = Optional.ofNullable(endIndex); + return this; + } + + /** + * End of the attributed segment, exclusive. + */ + public Builder endIndex(Optional endIndex) { + Utils.checkNotNull(endIndex, "endIndex"); + this.endIndex = endIndex; + return this; + } + + public URLCitation build() { + + return new URLCitation( + url, title, startIndex, + endIndex); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"url_citation\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLContext.java b/src/main/java/com/google/genai/gaos/models/interactions/URLContext.java new file mode 100644 index 00000000000..6d3dae45a6a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLContext.java @@ -0,0 +1,99 @@ +/* +* 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.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.utils.LazySingletonValue; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + +/** + * URLContext + * + *

A tool that can be used by the model to fetch URL context. + */ +@SuppressWarnings("all") +public class URLContext { + + @JsonProperty("type") + private String type; + + @JsonCreator + public URLContext() { + this.type = Builder._SINGLETON_VALUE_Type.value(); + } + + public String type() { + return Utils.discriminatorToString(type); + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + URLContext other = (URLContext) o; + return + Utils.enhancedDeepEquals(this.type, other.type); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type); + } + + @Override + public String toString() { + return Utils.toString(URLContext.class, + "type", type); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public URLContext build() { + return new URLContext( + ); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"url_context\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallArguments.java b/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallArguments.java new file mode 100644 index 00000000000..829bdc58f85 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallArguments.java @@ -0,0 +1,152 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * URLContextCallArguments + * + *

The arguments to pass to the URL context. + */ +@SuppressWarnings("all") +public class URLContextCallArguments { + /** + * The URLs to fetch. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("urls") + private Optional> urls; + + @JsonCreator + public URLContextCallArguments( + @JsonProperty("urls") Optional> urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = urls; + } + + public URLContextCallArguments() { + this(Optional.empty()); + } + + /** + * The URLs to fetch. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> urls() { + return (Optional>) urls; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The URLs to fetch. + */ + public URLContextCallArguments withUrls(List urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = Optional.ofNullable(urls); + return this; + } + + + /** + * The URLs to fetch. + */ + public URLContextCallArguments withUrls(Optional> urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = urls; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + URLContextCallArguments other = (URLContextCallArguments) o; + return + Utils.enhancedDeepEquals(this.urls, other.urls); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + urls); + } + + @Override + public String toString() { + return Utils.toString(URLContextCallArguments.class, + "urls", urls); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> urls = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The URLs to fetch. + */ + public Builder urls(List urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = Optional.ofNullable(urls); + return this; + } + + /** + * The URLs to fetch. + */ + public Builder urls(Optional> urls) { + Utils.checkNotNull(urls, "urls"); + this.urls = urls; + return this; + } + + public URLContextCallArguments build() { + + return new URLContextCallArguments( + urls); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallDelta.java new file mode 100644 index 00000000000..c37737a1b65 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallDelta.java @@ -0,0 +1,206 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class URLContextCallDelta { + + @JsonProperty("type") + private String type; + + /** + * The arguments to pass to the URL context. + */ + @JsonProperty("arguments") + private URLContextCallArguments arguments; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public URLContextCallDelta( + @JsonProperty("arguments") URLContextCallArguments arguments, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(arguments, "arguments"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.arguments = arguments; + this.signature = signature; + } + + public URLContextCallDelta( + URLContextCallArguments arguments) { + this(arguments, Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The arguments to pass to the URL context. + */ + @JsonIgnore + public URLContextCallArguments arguments() { + return arguments; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The arguments to pass to the URL context. + */ + public URLContextCallDelta withArguments(URLContextCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + /** + * A signature hash for backend validation. + */ + public URLContextCallDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public URLContextCallDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + URLContextCallDelta other = (URLContextCallDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.arguments, other.arguments) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, arguments, signature); + } + + @Override + public String toString() { + return Utils.toString(URLContextCallDelta.class, + "type", type, + "arguments", arguments, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private URLContextCallArguments arguments; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The arguments to pass to the URL context. + */ + public Builder arguments(URLContextCallArguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public URLContextCallDelta build() { + + return new URLContextCallDelta( + arguments, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"url_context_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallStep.java b/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallStep.java new file mode 100644 index 00000000000..749a2569459 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLContextCallStep.java @@ -0,0 +1,252 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * URLContextCallStep + * + *

URL context call step. + */ +@SuppressWarnings("all") +public class URLContextCallStep { + + @JsonProperty("type") + private String type; + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonProperty("id") + private String id; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + /** + * The arguments to pass to the URL context. + */ + @JsonProperty("arguments") + private Arguments arguments; + + @JsonCreator + public URLContextCallStep( + @JsonProperty("id") String id, + @JsonProperty("signature") Optional signature, + @JsonProperty("arguments") Arguments arguments) { + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(signature, "signature"); + Utils.checkNotNull(arguments, "arguments"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.id = id; + this.signature = signature; + this.arguments = arguments; + } + + public URLContextCallStep( + String id, + Arguments arguments) { + this(id, Optional.empty(), arguments); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. A unique ID for this specific tool call. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + /** + * The arguments to pass to the URL context. + */ + @JsonIgnore + public Arguments arguments() { + return arguments; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public URLContextCallStep withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * A signature hash for backend validation. + */ + public URLContextCallStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public URLContextCallStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + /** + * The arguments to pass to the URL context. + */ + public URLContextCallStep withArguments(Arguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + URLContextCallStep other = (URLContextCallStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.signature, other.signature) && + Utils.enhancedDeepEquals(this.arguments, other.arguments); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, id, signature, + arguments); + } + + @Override + public String toString() { + return Utils.toString(URLContextCallStep.class, + "type", type, + "id", id, + "signature", signature, + "arguments", arguments); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String id; + + private Optional signature = Optional.empty(); + + private Arguments arguments; + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. A unique ID for this specific tool call. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + + /** + * The arguments to pass to the URL context. + */ + public Builder arguments(Arguments arguments) { + Utils.checkNotNull(arguments, "arguments"); + this.arguments = arguments; + return this; + } + + public URLContextCallStep build() { + + return new URLContextCallStep( + id, signature, arguments); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"url_context_call\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLContextResult.java b/src/main/java/com/google/genai/gaos/models/interactions/URLContextResult.java new file mode 100644 index 00000000000..63598c122c9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLContextResult.java @@ -0,0 +1,211 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * URLContextResult + * + *

The result of the URL context. + */ +@SuppressWarnings("all") +public class URLContextResult { + /** + * The URL that was fetched. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("url") + private Optional url; + + /** + * The status of the URL retrieval. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("status") + private Optional status; + + @JsonCreator + public URLContextResult( + @JsonProperty("url") Optional url, + @JsonProperty("status") Optional status) { + Utils.checkNotNull(url, "url"); + Utils.checkNotNull(status, "status"); + this.url = url; + this.status = status; + } + + public URLContextResult() { + this(Optional.empty(), Optional.empty()); + } + + /** + * The URL that was fetched. + */ + @JsonIgnore + public Optional url() { + return url; + } + + /** + * The status of the URL retrieval. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional status() { + return (Optional) status; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The URL that was fetched. + */ + public URLContextResult withUrl(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + + /** + * The URL that was fetched. + */ + public URLContextResult withUrl(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + /** + * The status of the URL retrieval. + */ + public URLContextResult withStatus(URLContextResultStatus status) { + Utils.checkNotNull(status, "status"); + this.status = Optional.ofNullable(status); + return this; + } + + + /** + * The status of the URL retrieval. + */ + public URLContextResult withStatus(Optional status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + URLContextResult other = (URLContextResult) o; + return + Utils.enhancedDeepEquals(this.url, other.url) && + Utils.enhancedDeepEquals(this.status, other.status); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + url, status); + } + + @Override + public String toString() { + return Utils.toString(URLContextResult.class, + "url", url, + "status", status); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional url = Optional.empty(); + + private Optional status = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The URL that was fetched. + */ + public Builder url(String url) { + Utils.checkNotNull(url, "url"); + this.url = Optional.ofNullable(url); + return this; + } + + /** + * The URL that was fetched. + */ + public Builder url(Optional url) { + Utils.checkNotNull(url, "url"); + this.url = url; + return this; + } + + + /** + * The status of the URL retrieval. + */ + public Builder status(URLContextResultStatus status) { + Utils.checkNotNull(status, "status"); + this.status = Optional.ofNullable(status); + return this; + } + + /** + * The status of the URL retrieval. + */ + public Builder status(Optional status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + public URLContextResult build() { + + return new URLContextResult( + url, status); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultDelta.java new file mode 100644 index 00000000000..c8d30215e93 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultDelta.java @@ -0,0 +1,241 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + + +@SuppressWarnings("all") +public class URLContextResultDelta { + + @JsonProperty("type") + private String type; + + + @JsonProperty("result") + private List result; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("is_error") + private Optional isError; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public URLContextResultDelta( + @JsonProperty("result") List result, + @JsonProperty("is_error") Optional isError, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(isError, "isError"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.isError = isError; + this.signature = signature; + } + + public URLContextResultDelta( + List result) { + this(result, Optional.empty(), Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public List result() { + return result; + } + + @JsonIgnore + public Optional isError() { + return isError; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + public URLContextResultDelta withResult(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + public URLContextResultDelta withIsError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + + public URLContextResultDelta withIsError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + /** + * A signature hash for backend validation. + */ + public URLContextResultDelta withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public URLContextResultDelta withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + URLContextResultDelta other = (URLContextResultDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.isError, other.isError) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, isError, + signature); + } + + @Override + public String toString() { + return Utils.toString(URLContextResultDelta.class, + "type", type, + "result", result, + "isError", isError, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private List result; + + private Optional isError = Optional.empty(); + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder result(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + public Builder isError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + public Builder isError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public URLContextResultDelta build() { + + return new URLContextResultDelta( + result, isError, signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"url_context_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultStatus.java b/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultStatus.java new file mode 100644 index 00000000000..2b56f45e846 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultStatus.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. +*/ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * URLContextResultStatus + * + *

The status of the URL retrieval. + */ +@SuppressWarnings("all") +public enum URLContextResultStatus { + SUCCESS("success"), + ERROR("error"), + PAYWALL("paywall"), + UNSAFE("unsafe"); + + @JsonValue + private final String value; + + URLContextResultStatus(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (URLContextResultStatus o: URLContextResultStatus.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultStep.java b/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultStep.java new file mode 100644 index 00000000000..189a70fed66 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/URLContextResultStep.java @@ -0,0 +1,316 @@ +/* +* 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.JsonIgnore; +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 java.lang.Boolean; +import java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + +/** + * URLContextResultStep + * + *

URL context result step. + */ +@SuppressWarnings("all") +public class URLContextResultStep { + + @JsonProperty("type") + private String type; + + /** + * Required. The results of the URL context. + */ + @JsonProperty("result") + private List result; + + /** + * Whether the URL context resulted in an error. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("is_error") + private Optional isError; + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonProperty("call_id") + private String callId; + + /** + * A signature hash for backend validation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signature") + private Optional signature; + + @JsonCreator + public URLContextResultStep( + @JsonProperty("result") List result, + @JsonProperty("is_error") Optional isError, + @JsonProperty("call_id") String callId, + @JsonProperty("signature") Optional signature) { + Utils.checkNotNull(result, "result"); + Utils.checkNotNull(isError, "isError"); + Utils.checkNotNull(callId, "callId"); + Utils.checkNotNull(signature, "signature"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.result = result; + this.isError = isError; + this.callId = callId; + this.signature = signature; + } + + public URLContextResultStep( + List result, + String callId) { + this(result, Optional.empty(), callId, + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * Required. The results of the URL context. + */ + @JsonIgnore + public List result() { + return result; + } + + /** + * Whether the URL context resulted in an error. + */ + @JsonIgnore + public Optional isError() { + return isError; + } + + /** + * Required. ID to match the ID from the function call block. + */ + @JsonIgnore + public String callId() { + return callId; + } + + /** + * A signature hash for backend validation. + */ + @JsonIgnore + public Optional signature() { + return signature; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Required. The results of the URL context. + */ + public URLContextResultStep withResult(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + /** + * Whether the URL context resulted in an error. + */ + public URLContextResultStep withIsError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + + /** + * Whether the URL context resulted in an error. + */ + public URLContextResultStep withIsError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + /** + * Required. ID to match the ID from the function call block. + */ + public URLContextResultStep withCallId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + /** + * A signature hash for backend validation. + */ + public URLContextResultStep withSignature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + + /** + * A signature hash for backend validation. + */ + public URLContextResultStep withSignature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + URLContextResultStep other = (URLContextResultStep) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.result, other.result) && + Utils.enhancedDeepEquals(this.isError, other.isError) && + Utils.enhancedDeepEquals(this.callId, other.callId) && + Utils.enhancedDeepEquals(this.signature, other.signature); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, result, isError, + callId, signature); + } + + @Override + public String toString() { + return Utils.toString(URLContextResultStep.class, + "type", type, + "result", result, + "isError", isError, + "callId", callId, + "signature", signature); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private List result; + + private Optional isError = Optional.empty(); + + private String callId; + + private Optional signature = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Required. The results of the URL context. + */ + public Builder result(List result) { + Utils.checkNotNull(result, "result"); + this.result = result; + return this; + } + + + /** + * Whether the URL context resulted in an error. + */ + public Builder isError(boolean isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = Optional.ofNullable(isError); + return this; + } + + /** + * Whether the URL context resulted in an error. + */ + public Builder isError(Optional isError) { + Utils.checkNotNull(isError, "isError"); + this.isError = isError; + return this; + } + + + /** + * Required. ID to match the ID from the function call block. + */ + public Builder callId(String callId) { + Utils.checkNotNull(callId, "callId"); + this.callId = callId; + return this; + } + + + /** + * A signature hash for backend validation. + */ + public Builder signature(String signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = Optional.ofNullable(signature); + return this; + } + + /** + * A signature hash for backend validation. + */ + public Builder signature(Optional signature) { + Utils.checkNotNull(signature, "signature"); + this.signature = signature; + return this; + } + + public URLContextResultStep build() { + + return new URLContextResultStep( + result, isError, callId, + signature); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"url_context_result\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Usage.java b/src/main/java/com/google/genai/gaos/models/interactions/Usage.java new file mode 100644 index 00000000000..d0fdba7c163 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Usage.java @@ -0,0 +1,772 @@ +/* +* 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.JsonIgnore; +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 java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * Usage + * + *

Statistics on the interaction request's token usage. + */ +@SuppressWarnings("all") +public class Usage { + /** + * Number of tokens in the prompt (context). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("total_input_tokens") + private Optional totalInputTokens; + + /** + * A breakdown of input token usage by modality. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("input_tokens_by_modality") + private Optional> inputTokensByModality; + + /** + * Number of tokens in the cached part of the prompt (the cached content). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("total_cached_tokens") + private Optional totalCachedTokens; + + /** + * A breakdown of cached token usage by modality. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("cached_tokens_by_modality") + private Optional> cachedTokensByModality; + + /** + * Total number of tokens across all the generated responses. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("total_output_tokens") + private Optional totalOutputTokens; + + /** + * A breakdown of output token usage by modality. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("output_tokens_by_modality") + private Optional> outputTokensByModality; + + /** + * Number of tokens present in tool-use prompt(s). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("total_tool_use_tokens") + private Optional totalToolUseTokens; + + /** + * A breakdown of tool-use token usage by modality. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("tool_use_tokens_by_modality") + private Optional> toolUseTokensByModality; + + /** + * Number of tokens of thoughts for thinking models. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("total_thought_tokens") + private Optional totalThoughtTokens; + + /** + * Total token count for the interaction request (prompt + responses + other + * internal tokens). + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("total_tokens") + private Optional totalTokens; + + /** + * Grounding tool count. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("grounding_tool_count") + private Optional> groundingToolCount; + + @JsonCreator + public Usage( + @JsonProperty("total_input_tokens") Optional totalInputTokens, + @JsonProperty("input_tokens_by_modality") Optional> inputTokensByModality, + @JsonProperty("total_cached_tokens") Optional totalCachedTokens, + @JsonProperty("cached_tokens_by_modality") Optional> cachedTokensByModality, + @JsonProperty("total_output_tokens") Optional totalOutputTokens, + @JsonProperty("output_tokens_by_modality") Optional> outputTokensByModality, + @JsonProperty("total_tool_use_tokens") Optional totalToolUseTokens, + @JsonProperty("tool_use_tokens_by_modality") Optional> toolUseTokensByModality, + @JsonProperty("total_thought_tokens") Optional totalThoughtTokens, + @JsonProperty("total_tokens") Optional totalTokens, + @JsonProperty("grounding_tool_count") Optional> groundingToolCount) { + Utils.checkNotNull(totalInputTokens, "totalInputTokens"); + Utils.checkNotNull(inputTokensByModality, "inputTokensByModality"); + Utils.checkNotNull(totalCachedTokens, "totalCachedTokens"); + Utils.checkNotNull(cachedTokensByModality, "cachedTokensByModality"); + Utils.checkNotNull(totalOutputTokens, "totalOutputTokens"); + Utils.checkNotNull(outputTokensByModality, "outputTokensByModality"); + Utils.checkNotNull(totalToolUseTokens, "totalToolUseTokens"); + Utils.checkNotNull(toolUseTokensByModality, "toolUseTokensByModality"); + Utils.checkNotNull(totalThoughtTokens, "totalThoughtTokens"); + Utils.checkNotNull(totalTokens, "totalTokens"); + Utils.checkNotNull(groundingToolCount, "groundingToolCount"); + this.totalInputTokens = totalInputTokens; + this.inputTokensByModality = inputTokensByModality; + this.totalCachedTokens = totalCachedTokens; + this.cachedTokensByModality = cachedTokensByModality; + this.totalOutputTokens = totalOutputTokens; + this.outputTokensByModality = outputTokensByModality; + this.totalToolUseTokens = totalToolUseTokens; + this.toolUseTokensByModality = toolUseTokensByModality; + this.totalThoughtTokens = totalThoughtTokens; + this.totalTokens = totalTokens; + this.groundingToolCount = groundingToolCount; + } + + public Usage() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + /** + * Number of tokens in the prompt (context). + */ + @JsonIgnore + public Optional totalInputTokens() { + return totalInputTokens; + } + + /** + * A breakdown of input token usage by modality. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> inputTokensByModality() { + return (Optional>) inputTokensByModality; + } + + /** + * Number of tokens in the cached part of the prompt (the cached content). + */ + @JsonIgnore + public Optional totalCachedTokens() { + return totalCachedTokens; + } + + /** + * A breakdown of cached token usage by modality. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> cachedTokensByModality() { + return (Optional>) cachedTokensByModality; + } + + /** + * Total number of tokens across all the generated responses. + */ + @JsonIgnore + public Optional totalOutputTokens() { + return totalOutputTokens; + } + + /** + * A breakdown of output token usage by modality. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> outputTokensByModality() { + return (Optional>) outputTokensByModality; + } + + /** + * Number of tokens present in tool-use prompt(s). + */ + @JsonIgnore + public Optional totalToolUseTokens() { + return totalToolUseTokens; + } + + /** + * A breakdown of tool-use token usage by modality. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> toolUseTokensByModality() { + return (Optional>) toolUseTokensByModality; + } + + /** + * Number of tokens of thoughts for thinking models. + */ + @JsonIgnore + public Optional totalThoughtTokens() { + return totalThoughtTokens; + } + + /** + * Total token count for the interaction request (prompt + responses + other + * internal tokens). + */ + @JsonIgnore + public Optional totalTokens() { + return totalTokens; + } + + /** + * Grounding tool count. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> groundingToolCount() { + return (Optional>) groundingToolCount; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Number of tokens in the prompt (context). + */ + public Usage withTotalInputTokens(int totalInputTokens) { + Utils.checkNotNull(totalInputTokens, "totalInputTokens"); + this.totalInputTokens = Optional.ofNullable(totalInputTokens); + return this; + } + + + /** + * Number of tokens in the prompt (context). + */ + public Usage withTotalInputTokens(Optional totalInputTokens) { + Utils.checkNotNull(totalInputTokens, "totalInputTokens"); + this.totalInputTokens = totalInputTokens; + return this; + } + + /** + * A breakdown of input token usage by modality. + */ + public Usage withInputTokensByModality(List inputTokensByModality) { + Utils.checkNotNull(inputTokensByModality, "inputTokensByModality"); + this.inputTokensByModality = Optional.ofNullable(inputTokensByModality); + return this; + } + + + /** + * A breakdown of input token usage by modality. + */ + public Usage withInputTokensByModality(Optional> inputTokensByModality) { + Utils.checkNotNull(inputTokensByModality, "inputTokensByModality"); + this.inputTokensByModality = inputTokensByModality; + return this; + } + + /** + * Number of tokens in the cached part of the prompt (the cached content). + */ + public Usage withTotalCachedTokens(int totalCachedTokens) { + Utils.checkNotNull(totalCachedTokens, "totalCachedTokens"); + this.totalCachedTokens = Optional.ofNullable(totalCachedTokens); + return this; + } + + + /** + * Number of tokens in the cached part of the prompt (the cached content). + */ + public Usage withTotalCachedTokens(Optional totalCachedTokens) { + Utils.checkNotNull(totalCachedTokens, "totalCachedTokens"); + this.totalCachedTokens = totalCachedTokens; + return this; + } + + /** + * A breakdown of cached token usage by modality. + */ + public Usage withCachedTokensByModality(List cachedTokensByModality) { + Utils.checkNotNull(cachedTokensByModality, "cachedTokensByModality"); + this.cachedTokensByModality = Optional.ofNullable(cachedTokensByModality); + return this; + } + + + /** + * A breakdown of cached token usage by modality. + */ + public Usage withCachedTokensByModality(Optional> cachedTokensByModality) { + Utils.checkNotNull(cachedTokensByModality, "cachedTokensByModality"); + this.cachedTokensByModality = cachedTokensByModality; + return this; + } + + /** + * Total number of tokens across all the generated responses. + */ + public Usage withTotalOutputTokens(int totalOutputTokens) { + Utils.checkNotNull(totalOutputTokens, "totalOutputTokens"); + this.totalOutputTokens = Optional.ofNullable(totalOutputTokens); + return this; + } + + + /** + * Total number of tokens across all the generated responses. + */ + public Usage withTotalOutputTokens(Optional totalOutputTokens) { + Utils.checkNotNull(totalOutputTokens, "totalOutputTokens"); + this.totalOutputTokens = totalOutputTokens; + return this; + } + + /** + * A breakdown of output token usage by modality. + */ + public Usage withOutputTokensByModality(List outputTokensByModality) { + Utils.checkNotNull(outputTokensByModality, "outputTokensByModality"); + this.outputTokensByModality = Optional.ofNullable(outputTokensByModality); + return this; + } + + + /** + * A breakdown of output token usage by modality. + */ + public Usage withOutputTokensByModality(Optional> outputTokensByModality) { + Utils.checkNotNull(outputTokensByModality, "outputTokensByModality"); + this.outputTokensByModality = outputTokensByModality; + return this; + } + + /** + * Number of tokens present in tool-use prompt(s). + */ + public Usage withTotalToolUseTokens(int totalToolUseTokens) { + Utils.checkNotNull(totalToolUseTokens, "totalToolUseTokens"); + this.totalToolUseTokens = Optional.ofNullable(totalToolUseTokens); + return this; + } + + + /** + * Number of tokens present in tool-use prompt(s). + */ + public Usage withTotalToolUseTokens(Optional totalToolUseTokens) { + Utils.checkNotNull(totalToolUseTokens, "totalToolUseTokens"); + this.totalToolUseTokens = totalToolUseTokens; + return this; + } + + /** + * A breakdown of tool-use token usage by modality. + */ + public Usage withToolUseTokensByModality(List toolUseTokensByModality) { + Utils.checkNotNull(toolUseTokensByModality, "toolUseTokensByModality"); + this.toolUseTokensByModality = Optional.ofNullable(toolUseTokensByModality); + return this; + } + + + /** + * A breakdown of tool-use token usage by modality. + */ + public Usage withToolUseTokensByModality(Optional> toolUseTokensByModality) { + Utils.checkNotNull(toolUseTokensByModality, "toolUseTokensByModality"); + this.toolUseTokensByModality = toolUseTokensByModality; + return this; + } + + /** + * Number of tokens of thoughts for thinking models. + */ + public Usage withTotalThoughtTokens(int totalThoughtTokens) { + Utils.checkNotNull(totalThoughtTokens, "totalThoughtTokens"); + this.totalThoughtTokens = Optional.ofNullable(totalThoughtTokens); + return this; + } + + + /** + * Number of tokens of thoughts for thinking models. + */ + public Usage withTotalThoughtTokens(Optional totalThoughtTokens) { + Utils.checkNotNull(totalThoughtTokens, "totalThoughtTokens"); + this.totalThoughtTokens = totalThoughtTokens; + return this; + } + + /** + * Total token count for the interaction request (prompt + responses + other + * internal tokens). + */ + public Usage withTotalTokens(int totalTokens) { + Utils.checkNotNull(totalTokens, "totalTokens"); + this.totalTokens = Optional.ofNullable(totalTokens); + return this; + } + + + /** + * Total token count for the interaction request (prompt + responses + other + * internal tokens). + */ + public Usage withTotalTokens(Optional totalTokens) { + Utils.checkNotNull(totalTokens, "totalTokens"); + this.totalTokens = totalTokens; + return this; + } + + /** + * Grounding tool count. + */ + public Usage withGroundingToolCount(List groundingToolCount) { + Utils.checkNotNull(groundingToolCount, "groundingToolCount"); + this.groundingToolCount = Optional.ofNullable(groundingToolCount); + return this; + } + + + /** + * Grounding tool count. + */ + public Usage withGroundingToolCount(Optional> groundingToolCount) { + Utils.checkNotNull(groundingToolCount, "groundingToolCount"); + this.groundingToolCount = groundingToolCount; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Usage other = (Usage) o; + return + Utils.enhancedDeepEquals(this.totalInputTokens, other.totalInputTokens) && + Utils.enhancedDeepEquals(this.inputTokensByModality, other.inputTokensByModality) && + Utils.enhancedDeepEquals(this.totalCachedTokens, other.totalCachedTokens) && + Utils.enhancedDeepEquals(this.cachedTokensByModality, other.cachedTokensByModality) && + Utils.enhancedDeepEquals(this.totalOutputTokens, other.totalOutputTokens) && + Utils.enhancedDeepEquals(this.outputTokensByModality, other.outputTokensByModality) && + Utils.enhancedDeepEquals(this.totalToolUseTokens, other.totalToolUseTokens) && + Utils.enhancedDeepEquals(this.toolUseTokensByModality, other.toolUseTokensByModality) && + Utils.enhancedDeepEquals(this.totalThoughtTokens, other.totalThoughtTokens) && + Utils.enhancedDeepEquals(this.totalTokens, other.totalTokens) && + Utils.enhancedDeepEquals(this.groundingToolCount, other.groundingToolCount); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + totalInputTokens, inputTokensByModality, totalCachedTokens, + cachedTokensByModality, totalOutputTokens, outputTokensByModality, + totalToolUseTokens, toolUseTokensByModality, totalThoughtTokens, + totalTokens, groundingToolCount); + } + + @Override + public String toString() { + return Utils.toString(Usage.class, + "totalInputTokens", totalInputTokens, + "inputTokensByModality", inputTokensByModality, + "totalCachedTokens", totalCachedTokens, + "cachedTokensByModality", cachedTokensByModality, + "totalOutputTokens", totalOutputTokens, + "outputTokensByModality", outputTokensByModality, + "totalToolUseTokens", totalToolUseTokens, + "toolUseTokensByModality", toolUseTokensByModality, + "totalThoughtTokens", totalThoughtTokens, + "totalTokens", totalTokens, + "groundingToolCount", groundingToolCount); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional totalInputTokens = Optional.empty(); + + private Optional> inputTokensByModality = Optional.empty(); + + private Optional totalCachedTokens = Optional.empty(); + + private Optional> cachedTokensByModality = Optional.empty(); + + private Optional totalOutputTokens = Optional.empty(); + + private Optional> outputTokensByModality = Optional.empty(); + + private Optional totalToolUseTokens = Optional.empty(); + + private Optional> toolUseTokensByModality = Optional.empty(); + + private Optional totalThoughtTokens = Optional.empty(); + + private Optional totalTokens = Optional.empty(); + + private Optional> groundingToolCount = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Number of tokens in the prompt (context). + */ + public Builder totalInputTokens(int totalInputTokens) { + Utils.checkNotNull(totalInputTokens, "totalInputTokens"); + this.totalInputTokens = Optional.ofNullable(totalInputTokens); + return this; + } + + /** + * Number of tokens in the prompt (context). + */ + public Builder totalInputTokens(Optional totalInputTokens) { + Utils.checkNotNull(totalInputTokens, "totalInputTokens"); + this.totalInputTokens = totalInputTokens; + return this; + } + + + /** + * A breakdown of input token usage by modality. + */ + public Builder inputTokensByModality(List inputTokensByModality) { + Utils.checkNotNull(inputTokensByModality, "inputTokensByModality"); + this.inputTokensByModality = Optional.ofNullable(inputTokensByModality); + return this; + } + + /** + * A breakdown of input token usage by modality. + */ + public Builder inputTokensByModality(Optional> inputTokensByModality) { + Utils.checkNotNull(inputTokensByModality, "inputTokensByModality"); + this.inputTokensByModality = inputTokensByModality; + return this; + } + + + /** + * Number of tokens in the cached part of the prompt (the cached content). + */ + public Builder totalCachedTokens(int totalCachedTokens) { + Utils.checkNotNull(totalCachedTokens, "totalCachedTokens"); + this.totalCachedTokens = Optional.ofNullable(totalCachedTokens); + return this; + } + + /** + * Number of tokens in the cached part of the prompt (the cached content). + */ + public Builder totalCachedTokens(Optional totalCachedTokens) { + Utils.checkNotNull(totalCachedTokens, "totalCachedTokens"); + this.totalCachedTokens = totalCachedTokens; + return this; + } + + + /** + * A breakdown of cached token usage by modality. + */ + public Builder cachedTokensByModality(List cachedTokensByModality) { + Utils.checkNotNull(cachedTokensByModality, "cachedTokensByModality"); + this.cachedTokensByModality = Optional.ofNullable(cachedTokensByModality); + return this; + } + + /** + * A breakdown of cached token usage by modality. + */ + public Builder cachedTokensByModality(Optional> cachedTokensByModality) { + Utils.checkNotNull(cachedTokensByModality, "cachedTokensByModality"); + this.cachedTokensByModality = cachedTokensByModality; + return this; + } + + + /** + * Total number of tokens across all the generated responses. + */ + public Builder totalOutputTokens(int totalOutputTokens) { + Utils.checkNotNull(totalOutputTokens, "totalOutputTokens"); + this.totalOutputTokens = Optional.ofNullable(totalOutputTokens); + return this; + } + + /** + * Total number of tokens across all the generated responses. + */ + public Builder totalOutputTokens(Optional totalOutputTokens) { + Utils.checkNotNull(totalOutputTokens, "totalOutputTokens"); + this.totalOutputTokens = totalOutputTokens; + return this; + } + + + /** + * A breakdown of output token usage by modality. + */ + public Builder outputTokensByModality(List outputTokensByModality) { + Utils.checkNotNull(outputTokensByModality, "outputTokensByModality"); + this.outputTokensByModality = Optional.ofNullable(outputTokensByModality); + return this; + } + + /** + * A breakdown of output token usage by modality. + */ + public Builder outputTokensByModality(Optional> outputTokensByModality) { + Utils.checkNotNull(outputTokensByModality, "outputTokensByModality"); + this.outputTokensByModality = outputTokensByModality; + return this; + } + + + /** + * Number of tokens present in tool-use prompt(s). + */ + public Builder totalToolUseTokens(int totalToolUseTokens) { + Utils.checkNotNull(totalToolUseTokens, "totalToolUseTokens"); + this.totalToolUseTokens = Optional.ofNullable(totalToolUseTokens); + return this; + } + + /** + * Number of tokens present in tool-use prompt(s). + */ + public Builder totalToolUseTokens(Optional totalToolUseTokens) { + Utils.checkNotNull(totalToolUseTokens, "totalToolUseTokens"); + this.totalToolUseTokens = totalToolUseTokens; + return this; + } + + + /** + * A breakdown of tool-use token usage by modality. + */ + public Builder toolUseTokensByModality(List toolUseTokensByModality) { + Utils.checkNotNull(toolUseTokensByModality, "toolUseTokensByModality"); + this.toolUseTokensByModality = Optional.ofNullable(toolUseTokensByModality); + return this; + } + + /** + * A breakdown of tool-use token usage by modality. + */ + public Builder toolUseTokensByModality(Optional> toolUseTokensByModality) { + Utils.checkNotNull(toolUseTokensByModality, "toolUseTokensByModality"); + this.toolUseTokensByModality = toolUseTokensByModality; + return this; + } + + + /** + * Number of tokens of thoughts for thinking models. + */ + public Builder totalThoughtTokens(int totalThoughtTokens) { + Utils.checkNotNull(totalThoughtTokens, "totalThoughtTokens"); + this.totalThoughtTokens = Optional.ofNullable(totalThoughtTokens); + return this; + } + + /** + * Number of tokens of thoughts for thinking models. + */ + public Builder totalThoughtTokens(Optional totalThoughtTokens) { + Utils.checkNotNull(totalThoughtTokens, "totalThoughtTokens"); + this.totalThoughtTokens = totalThoughtTokens; + return this; + } + + + /** + * Total token count for the interaction request (prompt + responses + other + * internal tokens). + */ + public Builder totalTokens(int totalTokens) { + Utils.checkNotNull(totalTokens, "totalTokens"); + this.totalTokens = Optional.ofNullable(totalTokens); + return this; + } + + /** + * Total token count for the interaction request (prompt + responses + other + * internal tokens). + */ + public Builder totalTokens(Optional totalTokens) { + Utils.checkNotNull(totalTokens, "totalTokens"); + this.totalTokens = totalTokens; + return this; + } + + + /** + * Grounding tool count. + */ + public Builder groundingToolCount(List groundingToolCount) { + Utils.checkNotNull(groundingToolCount, "groundingToolCount"); + this.groundingToolCount = Optional.ofNullable(groundingToolCount); + return this; + } + + /** + * Grounding tool count. + */ + public Builder groundingToolCount(Optional> groundingToolCount) { + Utils.checkNotNull(groundingToolCount, "groundingToolCount"); + this.groundingToolCount = groundingToolCount; + return this; + } + + public Usage build() { + + return new Usage( + totalInputTokens, inputTokensByModality, totalCachedTokens, + cachedTokensByModality, totalOutputTokens, outputTokensByModality, + totalToolUseTokens, toolUseTokensByModality, totalThoughtTokens, + totalTokens, groundingToolCount); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/UserInputStep.java b/src/main/java/com/google/genai/gaos/models/interactions/UserInputStep.java new file mode 100644 index 00000000000..ee3f2f38ff8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/UserInputStep.java @@ -0,0 +1,155 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * UserInputStep + * + *

Input provided by the user. + */ +@SuppressWarnings("all") +public class UserInputStep { + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("content") + private Optional> content; + + + @JsonProperty("type") + private String type; + + @JsonCreator + public UserInputStep( + @JsonProperty("content") Optional> content) { + Utils.checkNotNull(content, "content"); + this.content = content; + this.type = Builder._SINGLETON_VALUE_Type.value(); + } + + public UserInputStep() { + this(Optional.empty()); + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> content() { + return (Optional>) content; + } + + @JsonIgnore + public String type() { + return type; + } + + public static Builder builder() { + return new Builder(); + } + + + public UserInputStep withContent(List content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + + public UserInputStep withContent(Optional> content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserInputStep other = (UserInputStep) o; + return + Utils.enhancedDeepEquals(this.content, other.content) && + Utils.enhancedDeepEquals(this.type, other.type); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + content, type); + } + + @Override + public String toString() { + return Utils.toString(UserInputStep.class, + "content", content, + "type", type); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> content = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder content(List content) { + Utils.checkNotNull(content, "content"); + this.content = Optional.ofNullable(content); + return this; + } + + public Builder content(Optional> content) { + Utils.checkNotNull(content, "content"); + this.content = content; + return this; + } + + public UserInputStep build() { + + return new UserInputStep( + content); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"user_input\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VertexAISearchConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/VertexAISearchConfig.java new file mode 100644 index 00000000000..21fe1b15cbb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VertexAISearchConfig.java @@ -0,0 +1,212 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * VertexAISearchConfig + * + *

Used to specify configuration for VertexAISearch. + */ +@SuppressWarnings("all") +public class VertexAISearchConfig { + /** + * Optional. Used to specify Vertex AI Search engine. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("engine") + private Optional engine; + + /** + * Optional. Used to specify Vertex AI Search datastores. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("datastores") + private Optional> datastores; + + @JsonCreator + public VertexAISearchConfig( + @JsonProperty("engine") Optional engine, + @JsonProperty("datastores") Optional> datastores) { + Utils.checkNotNull(engine, "engine"); + Utils.checkNotNull(datastores, "datastores"); + this.engine = engine; + this.datastores = datastores; + } + + public VertexAISearchConfig() { + this(Optional.empty(), Optional.empty()); + } + + /** + * Optional. Used to specify Vertex AI Search engine. + */ + @JsonIgnore + public Optional engine() { + return engine; + } + + /** + * Optional. Used to specify Vertex AI Search datastores. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> datastores() { + return (Optional>) datastores; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. Used to specify Vertex AI Search engine. + */ + public VertexAISearchConfig withEngine(String engine) { + Utils.checkNotNull(engine, "engine"); + this.engine = Optional.ofNullable(engine); + return this; + } + + + /** + * Optional. Used to specify Vertex AI Search engine. + */ + public VertexAISearchConfig withEngine(Optional engine) { + Utils.checkNotNull(engine, "engine"); + this.engine = engine; + return this; + } + + /** + * Optional. Used to specify Vertex AI Search datastores. + */ + public VertexAISearchConfig withDatastores(List datastores) { + Utils.checkNotNull(datastores, "datastores"); + this.datastores = Optional.ofNullable(datastores); + return this; + } + + + /** + * Optional. Used to specify Vertex AI Search datastores. + */ + public VertexAISearchConfig withDatastores(Optional> datastores) { + Utils.checkNotNull(datastores, "datastores"); + this.datastores = datastores; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VertexAISearchConfig other = (VertexAISearchConfig) o; + return + Utils.enhancedDeepEquals(this.engine, other.engine) && + Utils.enhancedDeepEquals(this.datastores, other.datastores); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + engine, datastores); + } + + @Override + public String toString() { + return Utils.toString(VertexAISearchConfig.class, + "engine", engine, + "datastores", datastores); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional engine = Optional.empty(); + + private Optional> datastores = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. Used to specify Vertex AI Search engine. + */ + public Builder engine(String engine) { + Utils.checkNotNull(engine, "engine"); + this.engine = Optional.ofNullable(engine); + return this; + } + + /** + * Optional. Used to specify Vertex AI Search engine. + */ + public Builder engine(Optional engine) { + Utils.checkNotNull(engine, "engine"); + this.engine = engine; + return this; + } + + + /** + * Optional. Used to specify Vertex AI Search datastores. + */ + public Builder datastores(List datastores) { + Utils.checkNotNull(datastores, "datastores"); + this.datastores = Optional.ofNullable(datastores); + return this; + } + + /** + * Optional. Used to specify Vertex AI Search datastores. + */ + public Builder datastores(Optional> datastores) { + Utils.checkNotNull(datastores, "datastores"); + this.datastores = datastores; + return this; + } + + public VertexAISearchConfig build() { + + return new VertexAISearchConfig( + engine, datastores); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VideoConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/VideoConfig.java new file mode 100644 index 00000000000..cf4fc559557 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoConfig.java @@ -0,0 +1,163 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * VideoConfig + * + *

Configuration options for video generation. + */ +@SuppressWarnings("all") +public class VideoConfig { + /** + * Optional task mode for video generation. If not specified, the model + * automatically determines the appropriate mode based on the provided text + * prompt and input media. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("task") + private Optional task; + + @JsonCreator + public VideoConfig( + @JsonProperty("task") Optional task) { + Utils.checkNotNull(task, "task"); + this.task = task; + } + + public VideoConfig() { + this(Optional.empty()); + } + + /** + * Optional task mode for video generation. If not specified, the model + * automatically determines the appropriate mode based on the provided text + * prompt and input media. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional task() { + return (Optional) task; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional task mode for video generation. If not specified, the model + * automatically determines the appropriate mode based on the provided text + * prompt and input media. + */ + public VideoConfig withTask(Task task) { + Utils.checkNotNull(task, "task"); + this.task = Optional.ofNullable(task); + return this; + } + + + /** + * Optional task mode for video generation. If not specified, the model + * automatically determines the appropriate mode based on the provided text + * prompt and input media. + */ + public VideoConfig withTask(Optional task) { + Utils.checkNotNull(task, "task"); + this.task = task; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VideoConfig other = (VideoConfig) o; + return + Utils.enhancedDeepEquals(this.task, other.task); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + task); + } + + @Override + public String toString() { + return Utils.toString(VideoConfig.class, + "task", task); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional task = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional task mode for video generation. If not specified, the model + * automatically determines the appropriate mode based on the provided text + * prompt and input media. + */ + public Builder task(Task task) { + Utils.checkNotNull(task, "task"); + this.task = Optional.ofNullable(task); + return this; + } + + /** + * Optional task mode for video generation. If not specified, the model + * automatically determines the appropriate mode based on the provided text + * prompt and input media. + */ + public Builder task(Optional task) { + Utils.checkNotNull(task, "task"); + this.task = task; + return this; + } + + public VideoConfig build() { + + return new VideoConfig( + task); + } + + } +} 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 new file mode 100644 index 00000000000..885097bbdd3 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoContent.java @@ -0,0 +1,338 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * VideoContent + * + *

A video content block. + */ +@SuppressWarnings("all") +public class VideoContent { + + @JsonProperty("type") + private String type; + + /** + * The video content. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("data") + private Optional data; + + /** + * The URI of the video. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + /** + * The mime type of the video. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("resolution") + private Optional resolution; + + @JsonCreator + public VideoContent( + @JsonProperty("data") Optional data, + @JsonProperty("uri") Optional uri, + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("resolution") Optional resolution) { + Utils.checkNotNull(data, "data"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(resolution, "resolution"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.data = data; + this.uri = uri; + this.mimeType = mimeType; + this.resolution = resolution; + } + + public VideoContent() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The video content. + */ + @JsonIgnore + public Optional data() { + return data; + } + + /** + * The URI of the video. + */ + @JsonIgnore + public Optional uri() { + return uri; + } + + /** + * The mime type of the video. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional resolution() { + return (Optional) resolution; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The video content. + */ + public VideoContent withData(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + + /** + * The video content. + */ + public VideoContent withData(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + /** + * The URI of the video. + */ + public VideoContent withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + /** + * The URI of the video. + */ + public VideoContent withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + /** + * The mime type of the video. + */ + public VideoContent withMimeType(VideoContentMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + /** + * The mime type of the video. + */ + public VideoContent withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + public VideoContent withResolution(MediaResolution resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = Optional.ofNullable(resolution); + return this; + } + + + public VideoContent withResolution(Optional resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = resolution; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VideoContent other = (VideoContent) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.resolution, other.resolution); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, data, uri, + mimeType, resolution); + } + + @Override + public String toString() { + return Utils.toString(VideoContent.class, + "type", type, + "data", data, + "uri", uri, + "mimeType", mimeType, + "resolution", resolution); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional data = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + private Optional resolution = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The video content. + */ + public Builder data(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + /** + * The video content. + */ + public Builder data(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + + /** + * The URI of the video. + */ + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + /** + * The URI of the video. + */ + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + /** + * The mime type of the video. + */ + public Builder mimeType(VideoContentMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + /** + * The mime type of the video. + */ + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + public Builder resolution(MediaResolution resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = Optional.ofNullable(resolution); + return this; + } + + public Builder resolution(Optional resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = resolution; + return this; + } + + public VideoContent build() { + + return new VideoContent( + data, uri, mimeType, + resolution); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"video\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VideoContentMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/VideoContentMimeType.java new file mode 100644 index 00000000000..25c65715c6f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoContentMimeType.java @@ -0,0 +1,64 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * VideoContentMimeType + * + *

The mime type of the video. + */ +@SuppressWarnings("all") +public enum VideoContentMimeType { + VIDEO_MP4("video/mp4"), + VIDEO_MPEG("video/mpeg"), + VIDEO_MPG("video/mpg"), + VIDEO_MOV("video/mov"), + VIDEO_AVI("video/avi"), + VIDEO_X_FLV("video/x-flv"), + VIDEO_WEBM("video/webm"), + VIDEO_WMV("video/wmv"), + VIDEO3GPP("video/3gpp"); + + @JsonValue + private final String value; + + VideoContentMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (VideoContentMimeType o: VideoContentMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VideoDelta.java b/src/main/java/com/google/genai/gaos/models/interactions/VideoDelta.java new file mode 100644 index 00000000000..c4e228f6bd3 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoDelta.java @@ -0,0 +1,283 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class VideoDelta { + + @JsonProperty("type") + private String type; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("data") + private Optional data; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mime_type") + private Optional mimeType; + + + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("resolution") + private Optional resolution; + + @JsonCreator + public VideoDelta( + @JsonProperty("data") Optional data, + @JsonProperty("uri") Optional uri, + @JsonProperty("mime_type") Optional mimeType, + @JsonProperty("resolution") Optional resolution) { + Utils.checkNotNull(data, "data"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(mimeType, "mimeType"); + Utils.checkNotNull(resolution, "resolution"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.data = data; + this.uri = uri; + this.mimeType = mimeType; + this.resolution = resolution; + } + + public VideoDelta() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + @JsonIgnore + public Optional data() { + return data; + } + + @JsonIgnore + public Optional uri() { + return uri; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional mimeType() { + return (Optional) mimeType; + } + + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional resolution() { + return (Optional) resolution; + } + + public static Builder builder() { + return new Builder(); + } + + + public VideoDelta withData(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + + public VideoDelta withData(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + public VideoDelta withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + public VideoDelta withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + public VideoDelta withMimeType(VideoDeltaMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + + public VideoDelta withMimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + public VideoDelta withResolution(MediaResolution resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = Optional.ofNullable(resolution); + return this; + } + + + public VideoDelta withResolution(Optional resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = resolution; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VideoDelta other = (VideoDelta) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.mimeType, other.mimeType) && + Utils.enhancedDeepEquals(this.resolution, other.resolution); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, data, uri, + mimeType, resolution); + } + + @Override + public String toString() { + return Utils.toString(VideoDelta.class, + "type", type, + "data", data, + "uri", uri, + "mimeType", mimeType, + "resolution", resolution); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional data = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + private Optional resolution = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + public Builder data(String data) { + Utils.checkNotNull(data, "data"); + this.data = Optional.ofNullable(data); + return this; + } + + public Builder data(Optional data) { + Utils.checkNotNull(data, "data"); + this.data = data; + return this; + } + + + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + public Builder mimeType(VideoDeltaMimeType mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + public Builder mimeType(Optional mimeType) { + Utils.checkNotNull(mimeType, "mimeType"); + this.mimeType = mimeType; + return this; + } + + + public Builder resolution(MediaResolution resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = Optional.ofNullable(resolution); + return this; + } + + public Builder resolution(Optional resolution) { + Utils.checkNotNull(resolution, "resolution"); + this.resolution = resolution; + return this; + } + + public VideoDelta build() { + + return new VideoDelta( + data, uri, mimeType, + resolution); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"video\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VideoDeltaMimeType.java b/src/main/java/com/google/genai/gaos/models/interactions/VideoDeltaMimeType.java new file mode 100644 index 00000000000..952865f50c2 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoDeltaMimeType.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. +*/ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; +import java.util.Objects; +import java.util.Optional; + +@SuppressWarnings("all") +public enum VideoDeltaMimeType { + VIDEO_MP4("video/mp4"), + VIDEO_MPEG("video/mpeg"), + VIDEO_MPG("video/mpg"), + VIDEO_MOV("video/mov"), + VIDEO_AVI("video/avi"), + VIDEO_X_FLV("video/x-flv"), + VIDEO_WEBM("video/webm"), + VIDEO_WMV("video/wmv"), + VIDEO3GPP("video/3gpp"); + + @JsonValue + private final String value; + + VideoDeltaMimeType(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (VideoDeltaMimeType o: VideoDeltaMimeType.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + 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 new file mode 100644 index 00000000000..bce82ece090 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormat.java @@ -0,0 +1,361 @@ +/* +* 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.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * VideoResponseFormat + * + *

Configuration for video output format. + */ +@SuppressWarnings("all") +public class VideoResponseFormat { + + @JsonProperty("type") + private String type; + + /** + * The delivery mode for the video output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("delivery") + private Optional delivery; + + /** + * The GCS URI to store the video output. Required for Vertex if delivery mode + * is URI. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("gcs_uri") + private Optional gcsUri; + + /** + * The aspect ratio for the video output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("aspect_ratio") + private Optional aspectRatio; + + /** + * The duration for the video output. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("duration") + private Optional duration; + + @JsonCreator + public VideoResponseFormat( + @JsonProperty("delivery") Optional delivery, + @JsonProperty("gcs_uri") Optional gcsUri, + @JsonProperty("aspect_ratio") Optional aspectRatio, + @JsonProperty("duration") Optional duration) { + Utils.checkNotNull(delivery, "delivery"); + Utils.checkNotNull(gcsUri, "gcsUri"); + Utils.checkNotNull(aspectRatio, "aspectRatio"); + Utils.checkNotNull(duration, "duration"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.delivery = delivery; + this.gcsUri = gcsUri; + this.aspectRatio = aspectRatio; + this.duration = duration; + } + + public VideoResponseFormat() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + @JsonIgnore + public String type() { + return type; + } + + /** + * The delivery mode for the video output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional delivery() { + return (Optional) delivery; + } + + /** + * The GCS URI to store the video output. Required for Vertex if delivery mode + * is URI. + */ + @JsonIgnore + public Optional gcsUri() { + return gcsUri; + } + + /** + * The aspect ratio for the video output. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional aspectRatio() { + return (Optional) aspectRatio; + } + + /** + * The duration for the video output. + */ + @JsonIgnore + public Optional duration() { + return duration; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The delivery mode for the video output. + */ + public VideoResponseFormat withDelivery(VideoResponseFormatDelivery delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = Optional.ofNullable(delivery); + return this; + } + + + /** + * The delivery mode for the video output. + */ + public VideoResponseFormat withDelivery(Optional delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = delivery; + return this; + } + + /** + * The GCS URI to store the video output. Required for Vertex if delivery mode + * is URI. + */ + public VideoResponseFormat withGcsUri(String gcsUri) { + Utils.checkNotNull(gcsUri, "gcsUri"); + this.gcsUri = Optional.ofNullable(gcsUri); + return this; + } + + + /** + * The GCS URI to store the video output. Required for Vertex if delivery mode + * is URI. + */ + public VideoResponseFormat withGcsUri(Optional gcsUri) { + Utils.checkNotNull(gcsUri, "gcsUri"); + this.gcsUri = gcsUri; + return this; + } + + /** + * The aspect ratio for the video output. + */ + public VideoResponseFormat withAspectRatio(VideoResponseFormatAspectRatio aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = Optional.ofNullable(aspectRatio); + return this; + } + + + /** + * The aspect ratio for the video output. + */ + public VideoResponseFormat withAspectRatio(Optional aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = aspectRatio; + return this; + } + + /** + * The duration for the video output. + */ + public VideoResponseFormat withDuration(String duration) { + Utils.checkNotNull(duration, "duration"); + this.duration = Optional.ofNullable(duration); + return this; + } + + + /** + * The duration for the video output. + */ + public VideoResponseFormat withDuration(Optional duration) { + Utils.checkNotNull(duration, "duration"); + this.duration = duration; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VideoResponseFormat other = (VideoResponseFormat) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.delivery, other.delivery) && + Utils.enhancedDeepEquals(this.gcsUri, other.gcsUri) && + Utils.enhancedDeepEquals(this.aspectRatio, other.aspectRatio) && + Utils.enhancedDeepEquals(this.duration, other.duration); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, delivery, gcsUri, + aspectRatio, duration); + } + + @Override + public String toString() { + return Utils.toString(VideoResponseFormat.class, + "type", type, + "delivery", delivery, + "gcsUri", gcsUri, + "aspectRatio", aspectRatio, + "duration", duration); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional delivery = Optional.empty(); + + private Optional gcsUri = Optional.empty(); + + private Optional aspectRatio = Optional.empty(); + + private Optional duration = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The delivery mode for the video output. + */ + public Builder delivery(VideoResponseFormatDelivery delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = Optional.ofNullable(delivery); + return this; + } + + /** + * The delivery mode for the video output. + */ + public Builder delivery(Optional delivery) { + Utils.checkNotNull(delivery, "delivery"); + this.delivery = delivery; + return this; + } + + + /** + * The GCS URI to store the video output. Required for Vertex if delivery mode + * is URI. + */ + public Builder gcsUri(String gcsUri) { + Utils.checkNotNull(gcsUri, "gcsUri"); + this.gcsUri = Optional.ofNullable(gcsUri); + return this; + } + + /** + * The GCS URI to store the video output. Required for Vertex if delivery mode + * is URI. + */ + public Builder gcsUri(Optional gcsUri) { + Utils.checkNotNull(gcsUri, "gcsUri"); + this.gcsUri = gcsUri; + return this; + } + + + /** + * The aspect ratio for the video output. + */ + public Builder aspectRatio(VideoResponseFormatAspectRatio aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = Optional.ofNullable(aspectRatio); + return this; + } + + /** + * The aspect ratio for the video output. + */ + public Builder aspectRatio(Optional aspectRatio) { + Utils.checkNotNull(aspectRatio, "aspectRatio"); + this.aspectRatio = aspectRatio; + return this; + } + + + /** + * The duration for the video output. + */ + public Builder duration(String duration) { + Utils.checkNotNull(duration, "duration"); + this.duration = Optional.ofNullable(duration); + return this; + } + + /** + * The duration for the video output. + */ + public Builder duration(Optional duration) { + Utils.checkNotNull(duration, "duration"); + this.duration = duration; + return this; + } + + public VideoResponseFormat build() { + + return new VideoResponseFormat( + delivery, gcsUri, aspectRatio, + duration); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"video\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormatAspectRatio.java b/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormatAspectRatio.java new file mode 100644 index 00000000000..26f525c4866 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormatAspectRatio.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * VideoResponseFormatAspectRatio + * + *

The aspect ratio for the video output. + */ +@SuppressWarnings("all") +public enum VideoResponseFormatAspectRatio { + ONE_HUNDRED_AND_SIXTY_NINE("16:9"), + NINE_HUNDRED_AND_SIXTEEN("9:16"); + + @JsonValue + private final String value; + + VideoResponseFormatAspectRatio(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (VideoResponseFormatAspectRatio o: VideoResponseFormatAspectRatio.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormatDelivery.java b/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormatDelivery.java new file mode 100644 index 00000000000..b3c39767bc5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormatDelivery.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * VideoResponseFormatDelivery + * + *

The delivery mode for the video output. + */ +@SuppressWarnings("all") +public enum VideoResponseFormatDelivery { + INLINE("inline"), + URI("uri"); + + @JsonValue + private final String value; + + VideoResponseFormatDelivery(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (VideoResponseFormatDelivery o: VideoResponseFormatDelivery.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Visualization.java b/src/main/java/com/google/genai/gaos/models/interactions/Visualization.java new file mode 100644 index 00000000000..5adece58827 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Visualization.java @@ -0,0 +1,57 @@ +/* +* 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 java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * Visualization + * + *

Whether to include visualizations in the response. + */ +@SuppressWarnings("all") +public enum Visualization { + OFF("off"), + AUTO("auto"); + + @JsonValue + private final String value; + + Visualization(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (Visualization o: Visualization.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/WebhookConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/WebhookConfig.java new file mode 100644 index 00000000000..71b8c5602d1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/WebhookConfig.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.JsonIgnore; +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 java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * WebhookConfig + * + *

Message for configuring webhook events for a request. + */ +@SuppressWarnings("all") +public class WebhookConfig { + /** + * Optional. If set, these webhook URIs will be used for webhook events instead of the + * registered webhooks. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uris") + private Optional> uris; + + /** + * Optional. The user metadata that will be returned on each event emission to the + * webhooks. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("user_metadata") + private Optional> userMetadata; + + @JsonCreator + public WebhookConfig( + @JsonProperty("uris") Optional> uris, + @JsonProperty("user_metadata") Optional> userMetadata) { + Utils.checkNotNull(uris, "uris"); + Utils.checkNotNull(userMetadata, "userMetadata"); + this.uris = uris; + this.userMetadata = userMetadata; + } + + public WebhookConfig() { + this(Optional.empty(), Optional.empty()); + } + + /** + * Optional. If set, these webhook URIs will be used for webhook events instead of the + * registered webhooks. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> uris() { + return (Optional>) uris; + } + + /** + * Optional. The user metadata that will be returned on each event emission to the + * webhooks. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> userMetadata() { + return (Optional>) userMetadata; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. If set, these webhook URIs will be used for webhook events instead of the + * registered webhooks. + */ + public WebhookConfig withUris(List uris) { + Utils.checkNotNull(uris, "uris"); + this.uris = Optional.ofNullable(uris); + return this; + } + + + /** + * Optional. If set, these webhook URIs will be used for webhook events instead of the + * registered webhooks. + */ + public WebhookConfig withUris(Optional> uris) { + Utils.checkNotNull(uris, "uris"); + this.uris = uris; + return this; + } + + /** + * Optional. The user metadata that will be returned on each event emission to the + * webhooks. + */ + public WebhookConfig withUserMetadata(Map userMetadata) { + Utils.checkNotNull(userMetadata, "userMetadata"); + this.userMetadata = Optional.ofNullable(userMetadata); + return this; + } + + + /** + * Optional. The user metadata that will be returned on each event emission to the + * webhooks. + */ + public WebhookConfig withUserMetadata(Optional> userMetadata) { + Utils.checkNotNull(userMetadata, "userMetadata"); + this.userMetadata = userMetadata; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookConfig other = (WebhookConfig) o; + return + Utils.enhancedDeepEquals(this.uris, other.uris) && + Utils.enhancedDeepEquals(this.userMetadata, other.userMetadata); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + uris, userMetadata); + } + + @Override + public String toString() { + return Utils.toString(WebhookConfig.class, + "uris", uris, + "userMetadata", userMetadata); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> uris = Optional.empty(); + + private Optional> userMetadata = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. If set, these webhook URIs will be used for webhook events instead of the + * registered webhooks. + */ + public Builder uris(List uris) { + Utils.checkNotNull(uris, "uris"); + this.uris = Optional.ofNullable(uris); + return this; + } + + /** + * Optional. If set, these webhook URIs will be used for webhook events instead of the + * registered webhooks. + */ + public Builder uris(Optional> uris) { + Utils.checkNotNull(uris, "uris"); + this.uris = uris; + return this; + } + + + /** + * Optional. The user metadata that will be returned on each event emission to the + * webhooks. + */ + public Builder userMetadata(Map userMetadata) { + Utils.checkNotNull(userMetadata, "userMetadata"); + this.userMetadata = Optional.ofNullable(userMetadata); + return this; + } + + /** + * Optional. The user metadata that will be returned on each event emission to the + * webhooks. + */ + public Builder userMetadata(Optional> userMetadata) { + Utils.checkNotNull(userMetadata, "userMetadata"); + this.userMetadata = userMetadata; + return this; + } + + public WebhookConfig build() { + + return new WebhookConfig( + uris, userMetadata); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdRequest.java b/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdRequest.java new file mode 100644 index 00000000000..a297aa130fe --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdRequest.java @@ -0,0 +1,183 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CancelInteractionByIdRequest { + /** + * The unique identifier of the interaction to cancel. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + @JsonCreator + public CancelInteractionByIdRequest( + String id, + Optional apiVersion) { + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(apiVersion, "apiVersion"); + this.id = id; + this.apiVersion = apiVersion; + } + + public CancelInteractionByIdRequest( + String id) { + this(id, Optional.empty()); + } + + /** + * The unique identifier of the interaction to cancel. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The unique identifier of the interaction to cancel. + */ + public CancelInteractionByIdRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * Which version of the API to use. + */ + public CancelInteractionByIdRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public CancelInteractionByIdRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CancelInteractionByIdRequest other = (CancelInteractionByIdRequest) o; + return + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + id, apiVersion); + } + + @Override + public String toString() { + return Utils.toString(CancelInteractionByIdRequest.class, + "id", id, + "apiVersion", apiVersion); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String id; + + private Optional apiVersion = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The unique identifier of the interaction to cancel. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CancelInteractionByIdRequest build() { + + return new CancelInteractionByIdRequest( + id, apiVersion); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdRequestBuilder.java new file mode 100644 index 00000000000..e25a8d15a47 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdRequestBuilder.java @@ -0,0 +1,96 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.CancelInteractionById; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class CancelInteractionByIdRequestBuilder { + + private String id; + private Optional apiVersion = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public CancelInteractionByIdRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public CancelInteractionByIdRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public CancelInteractionByIdRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public CancelInteractionByIdRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CancelInteractionByIdRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public CancelInteractionByIdRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private CancelInteractionByIdRequest buildRequest() { + + CancelInteractionByIdRequest request = new CancelInteractionByIdRequest(id, + apiVersion); + + return request; + } + + public CancelInteractionByIdResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new CancelInteractionById.Sync(sdkConfiguration, options, _headers); + CancelInteractionByIdRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdResponse.java b/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdResponse.java new file mode 100644 index 00000000000..6d15ee483b1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CancelInteractionByIdResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CancelInteractionByIdResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful cancellation of the interaction. + */ + private Optional interaction; + + @JsonCreator + public CancelInteractionByIdResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional interaction) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(interaction, "interaction"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.interaction = interaction; + } + + public CancelInteractionByIdResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful cancellation of the interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional interaction() { + return (Optional) interaction; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public CancelInteractionByIdResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public CancelInteractionByIdResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public CancelInteractionByIdResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful cancellation of the interaction. + */ + public CancelInteractionByIdResponse withInteraction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + + /** + * Successful cancellation of the interaction. + */ + public CancelInteractionByIdResponse withInteraction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CancelInteractionByIdResponse other = (CancelInteractionByIdResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.interaction, other.interaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + interaction); + } + + @Override + public String toString() { + return Utils.toString(CancelInteractionByIdResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "interaction", interaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional interaction = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful cancellation of the interaction. + */ + public Builder interaction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + /** + * Successful cancellation of the interaction. + */ + public Builder interaction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + public CancelInteractionByIdResponse build() { + + return new CancelInteractionByIdResponse( + contentType, statusCode, rawResponse, + interaction); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateAgentRequest.java b/src/main/java/com/google/genai/gaos/models/operations/CreateAgentRequest.java new file mode 100644 index 00000000000..b027ba77c9c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateAgentRequest.java @@ -0,0 +1,184 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateAgentRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * The request body. + */ + @SpeakeasyMetadata("request:mediaType=application/json") + private Agent body; + + @JsonCreator + public CreateAgentRequest( + Optional apiVersion, + Agent body) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(body, "body"); + this.apiVersion = apiVersion; + this.body = body; + } + + public CreateAgentRequest( + Agent body) { + this(Optional.empty(), body); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * The request body. + */ + @JsonIgnore + public Agent body() { + return body; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public CreateAgentRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public CreateAgentRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * The request body. + */ + public CreateAgentRequest withBody(Agent body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateAgentRequest other = (CreateAgentRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.body, other.body); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, body); + } + + @Override + public String toString() { + return Utils.toString(CreateAgentRequest.class, + "apiVersion", apiVersion, + "body", body); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private Agent body; + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * The request body. + */ + public Builder body(Agent body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateAgentRequest build() { + + return new CreateAgentRequest( + apiVersion, body); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateAgentRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/CreateAgentRequestBuilder.java new file mode 100644 index 00000000000..1b7d4d6807e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateAgentRequestBuilder.java @@ -0,0 +1,97 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.operations.CreateAgent; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class CreateAgentRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private Agent body; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public CreateAgentRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public CreateAgentRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public CreateAgentRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CreateAgentRequestBuilder body(Agent body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateAgentRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public CreateAgentRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private CreateAgentRequest buildRequest() { + + CreateAgentRequest request = new CreateAgentRequest(apiVersion, + body); + + return request; + } + + public CreateAgentResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new CreateAgent.Sync(sdkConfiguration, options, _headers); + CreateAgentRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateAgentResponse.java b/src/main/java/com/google/genai/gaos/models/operations/CreateAgentResponse.java new file mode 100644 index 00000000000..51ae458ce3a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateAgentResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateAgentResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional agent; + + @JsonCreator + public CreateAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional agent) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(agent, "agent"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.agent = agent; + } + + public CreateAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional agent() { + return (Optional) agent; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public CreateAgentResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public CreateAgentResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public CreateAgentResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public CreateAgentResponse withAgent(Agent agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + + /** + * Successful operation + */ + public CreateAgentResponse withAgent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateAgentResponse other = (CreateAgentResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.agent, other.agent); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + agent); + } + + @Override + public String toString() { + return Utils.toString(CreateAgentResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "agent", agent); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional agent = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder agent(Agent agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + /** + * Successful operation + */ + public Builder agent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + public CreateAgentResponse build() { + + return new CreateAgentResponse( + contentType, statusCode, rawResponse, + agent); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequest.java b/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequest.java new file mode 100644 index 00000000000..98aadb7b17f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequest.java @@ -0,0 +1,183 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateInteractionRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * The request body. + */ + @SpeakeasyMetadata("request:mediaType=application/json") + private CreateInteractionRequestBody body; + + @JsonCreator + public CreateInteractionRequest( + Optional apiVersion, + CreateInteractionRequestBody body) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(body, "body"); + this.apiVersion = apiVersion; + this.body = body; + } + + public CreateInteractionRequest( + CreateInteractionRequestBody body) { + this(Optional.empty(), body); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * The request body. + */ + @JsonIgnore + public CreateInteractionRequestBody body() { + return body; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public CreateInteractionRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public CreateInteractionRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * The request body. + */ + public CreateInteractionRequest withBody(CreateInteractionRequestBody body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateInteractionRequest other = (CreateInteractionRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.body, other.body); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, body); + } + + @Override + public String toString() { + return Utils.toString(CreateInteractionRequest.class, + "apiVersion", apiVersion, + "body", body); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private CreateInteractionRequestBody body; + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * The request body. + */ + public Builder body(CreateInteractionRequestBody body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateInteractionRequest build() { + + return new CreateInteractionRequest( + apiVersion, body); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequestBody.java b/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequestBody.java new file mode 100644 index 00000000000..d0029e43cbd --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequestBody.java @@ -0,0 +1,118 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.genai.gaos.models.interactions.CreateAgentInteraction; +import com.google.genai.gaos.models.interactions.CreateModelInteraction; +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; + +/** + * CreateInteractionRequestBody + * + *

The request body. + */ +@JsonDeserialize(using = CreateInteractionRequestBody._Deserializer.class) +@SuppressWarnings("all") +public class CreateInteractionRequestBody { + + @JsonValue + private final TypedObject value; + + private CreateInteractionRequestBody(TypedObject value) { + this.value = value; + } + + public static CreateInteractionRequestBody of(CreateModelInteraction value) { + Utils.checkNotNull(value, "value"); + return new CreateInteractionRequestBody(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + public static CreateInteractionRequestBody of(CreateAgentInteraction value) { + Utils.checkNotNull(value, "value"); + return new CreateInteractionRequestBody(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference<>(){})); + } + + /** + * Returns an instance of one of these types: + *

    + *
  • {@code com.google.genai.gaos.models.interactions.CreateModelInteraction}
  • + *
  • {@code com.google.genai.gaos.models.interactions.CreateAgentInteraction}
  • + *
+ * + *

Use {@code instanceof} to determine what type is returned. For example: + * + *

+     * if (obj.value() instanceof String) {
+     *     String answer = (String) obj.value();
+     *     System.out.println("answer=" + answer);
+     * }
+     * 
+ * + * @return value of oneOf type + **/ + public java.lang.Object value() { + return value.value(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateInteractionRequestBody other = (CreateInteractionRequestBody) 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(CreateInteractionRequestBody.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(CreateInteractionRequestBody.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequestBuilder.java new file mode 100644 index 00000000000..a90e89f62f5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionRequestBuilder.java @@ -0,0 +1,96 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.CreateInteraction; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class CreateInteractionRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private CreateInteractionRequestBody body; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public CreateInteractionRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public CreateInteractionRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public CreateInteractionRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CreateInteractionRequestBuilder body(CreateInteractionRequestBody body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateInteractionRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public CreateInteractionRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private CreateInteractionRequest buildRequest() { + + CreateInteractionRequest request = new CreateInteractionRequest(apiVersion, + body); + + return request; + } + + public CreateInteractionResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new CreateInteraction.Sync(sdkConfiguration, options, _headers); + CreateInteractionRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionResponse.java b/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionResponse.java new file mode 100644 index 00000000000..f71b339db23 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateInteractionResponse.java @@ -0,0 +1,284 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.utils.EventStream; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateInteractionResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional interaction; + + @JsonCreator + public CreateInteractionResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional interaction) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(interaction, "interaction"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.interaction = interaction; + } + + public CreateInteractionResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional interaction() { + return (Optional) interaction; + } + // value overriden by x-speakeasy-sse-sentinel extension via reflection at runtime + private Optional _eventSentinel = Optional.empty(); + + public EventStream events() { + return new EventStream( + rawResponse.body(), + new TypeReference() {}, + Utils.mapper(), + _eventSentinel); + } + + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public CreateInteractionResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public CreateInteractionResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public CreateInteractionResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public CreateInteractionResponse withInteraction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + + /** + * Successful operation + */ + public CreateInteractionResponse withInteraction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateInteractionResponse other = (CreateInteractionResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.interaction, other.interaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + interaction); + } + + @Override + public String toString() { + return Utils.toString(CreateInteractionResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "interaction", interaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional interaction = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder interaction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + /** + * Successful operation + */ + public Builder interaction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + public CreateInteractionResponse build() { + + return new CreateInteractionResponse( + contentType, statusCode, rawResponse, + interaction); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookRequest.java b/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookRequest.java new file mode 100644 index 00000000000..32eab656d68 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookRequest.java @@ -0,0 +1,184 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.WebhookInput; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateWebhookRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * Required. The webhook to create. + */ + @SpeakeasyMetadata("request:mediaType=application/json") + private WebhookInput body; + + @JsonCreator + public CreateWebhookRequest( + Optional apiVersion, + WebhookInput body) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(body, "body"); + this.apiVersion = apiVersion; + this.body = body; + } + + public CreateWebhookRequest( + WebhookInput body) { + this(Optional.empty(), body); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * Required. The webhook to create. + */ + @JsonIgnore + public WebhookInput body() { + return body; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public CreateWebhookRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public CreateWebhookRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * Required. The webhook to create. + */ + public CreateWebhookRequest withBody(WebhookInput body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateWebhookRequest other = (CreateWebhookRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.body, other.body); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, body); + } + + @Override + public String toString() { + return Utils.toString(CreateWebhookRequest.class, + "apiVersion", apiVersion, + "body", body); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private WebhookInput body; + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * Required. The webhook to create. + */ + public Builder body(WebhookInput body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateWebhookRequest build() { + + return new CreateWebhookRequest( + apiVersion, body); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookRequestBuilder.java new file mode 100644 index 00000000000..9088b80148a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookRequestBuilder.java @@ -0,0 +1,97 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.webhooks.WebhookInput; +import com.google.genai.gaos.operations.CreateWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class CreateWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private WebhookInput body; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public CreateWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public CreateWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public CreateWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CreateWebhookRequestBuilder body(WebhookInput body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public CreateWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private CreateWebhookRequest buildRequest() { + + CreateWebhookRequest request = new CreateWebhookRequest(apiVersion, + body); + + return request; + } + + public CreateWebhookResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new CreateWebhook.Sync(sdkConfiguration, options, _headers); + CreateWebhookRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookResponse.java new file mode 100644 index 00000000000..abc75b52244 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/CreateWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateWebhookResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhook; + + @JsonCreator + public CreateWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhook) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhook, "webhook"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhook = webhook; + } + + public CreateWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhook() { + return (Optional) webhook; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public CreateWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public CreateWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public CreateWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public CreateWebhookResponse withWebhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + + /** + * Successful operation + */ + public CreateWebhookResponse withWebhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateWebhookResponse other = (CreateWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhook, other.webhook); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhook); + } + + @Override + public String toString() { + return Utils.toString(CreateWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhook", webhook); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhook = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + /** + * Successful operation + */ + public Builder webhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + public CreateWebhookResponse build() { + + return new CreateWebhookResponse( + contentType, statusCode, rawResponse, + webhook); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentRequest.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentRequest.java new file mode 100644 index 00000000000..47d53c7c459 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentRequest.java @@ -0,0 +1,172 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class DeleteAgentRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + @JsonCreator + public DeleteAgentRequest( + Optional apiVersion, + String id) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(id, "id"); + this.apiVersion = apiVersion; + this.id = id; + } + + public DeleteAgentRequest( + String id) { + this(Optional.empty(), id); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + @JsonIgnore + public String id() { + return id; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public DeleteAgentRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public DeleteAgentRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public DeleteAgentRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteAgentRequest other = (DeleteAgentRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.id, other.id); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, id); + } + + @Override + public String toString() { + return Utils.toString(DeleteAgentRequest.class, + "apiVersion", apiVersion, + "id", id); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private String id; + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public DeleteAgentRequest build() { + + return new DeleteAgentRequest( + apiVersion, id); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentRequestBuilder.java new file mode 100644 index 00000000000..31b11bc5ee9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentRequestBuilder.java @@ -0,0 +1,96 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.DeleteAgent; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class DeleteAgentRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public DeleteAgentRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public DeleteAgentRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public DeleteAgentRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public DeleteAgentRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public DeleteAgentRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public DeleteAgentRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private DeleteAgentRequest buildRequest() { + + DeleteAgentRequest request = new DeleteAgentRequest(apiVersion, + id); + + return request; + } + + public DeleteAgentResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new DeleteAgent.Sync(sdkConfiguration, options, _headers); + DeleteAgentRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentResponse.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentResponse.java new file mode 100644 index 00000000000..6b2a9d8615b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteAgentResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.interactions.Empty; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class DeleteAgentResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional empty; + + @JsonCreator + public DeleteAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional empty) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(empty, "empty"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.empty = empty; + } + + public DeleteAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional empty() { + return (Optional) empty; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public DeleteAgentResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public DeleteAgentResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public DeleteAgentResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public DeleteAgentResponse withEmpty(Empty empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = Optional.ofNullable(empty); + return this; + } + + + /** + * Successful operation + */ + public DeleteAgentResponse withEmpty(Optional empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = empty; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteAgentResponse other = (DeleteAgentResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.empty, other.empty); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + empty); + } + + @Override + public String toString() { + return Utils.toString(DeleteAgentResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "empty", empty); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional empty = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder empty(Empty empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = Optional.ofNullable(empty); + return this; + } + + /** + * Successful operation + */ + public Builder empty(Optional empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = empty; + return this; + } + + public DeleteAgentResponse build() { + + return new DeleteAgentResponse( + contentType, statusCode, rawResponse, + empty); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionRequest.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionRequest.java new file mode 100644 index 00000000000..25ae1420b5a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionRequest.java @@ -0,0 +1,183 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class DeleteInteractionRequest { + /** + * The unique identifier of the interaction to delete. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + @JsonCreator + public DeleteInteractionRequest( + String id, + Optional apiVersion) { + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(apiVersion, "apiVersion"); + this.id = id; + this.apiVersion = apiVersion; + } + + public DeleteInteractionRequest( + String id) { + this(id, Optional.empty()); + } + + /** + * The unique identifier of the interaction to delete. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The unique identifier of the interaction to delete. + */ + public DeleteInteractionRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * Which version of the API to use. + */ + public DeleteInteractionRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public DeleteInteractionRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteInteractionRequest other = (DeleteInteractionRequest) o; + return + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + id, apiVersion); + } + + @Override + public String toString() { + return Utils.toString(DeleteInteractionRequest.class, + "id", id, + "apiVersion", apiVersion); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String id; + + private Optional apiVersion = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The unique identifier of the interaction to delete. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public DeleteInteractionRequest build() { + + return new DeleteInteractionRequest( + id, apiVersion); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionRequestBuilder.java new file mode 100644 index 00000000000..e071b4ed7d9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionRequestBuilder.java @@ -0,0 +1,96 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.DeleteInteraction; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class DeleteInteractionRequestBuilder { + + private String id; + private Optional apiVersion = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public DeleteInteractionRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public DeleteInteractionRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public DeleteInteractionRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public DeleteInteractionRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public DeleteInteractionRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public DeleteInteractionRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private DeleteInteractionRequest buildRequest() { + + DeleteInteractionRequest request = new DeleteInteractionRequest(id, + apiVersion); + + return request; + } + + public DeleteInteractionResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new DeleteInteraction.Sync(sdkConfiguration, options, _headers); + DeleteInteractionRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionResponse.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionResponse.java new file mode 100644 index 00000000000..7ef36206d0d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteInteractionResponse.java @@ -0,0 +1,198 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.net.http.HttpResponse; + + +@SuppressWarnings("all") +public class DeleteInteractionResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + @JsonCreator + public DeleteInteractionResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public DeleteInteractionResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public DeleteInteractionResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public DeleteInteractionResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteInteractionResponse other = (DeleteInteractionResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse); + } + + @Override + public String toString() { + return Utils.toString(DeleteInteractionResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + public DeleteInteractionResponse build() { + + return new DeleteInteractionResponse( + contentType, statusCode, rawResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookRequest.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookRequest.java new file mode 100644 index 00000000000..31f6d6b6c8d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookRequest.java @@ -0,0 +1,187 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class DeleteWebhookRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * Required. The ID of the webhook to delete. + * Format: `{webhook_id}` + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + @JsonCreator + public DeleteWebhookRequest( + Optional apiVersion, + String id) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(id, "id"); + this.apiVersion = apiVersion; + this.id = id; + } + + public DeleteWebhookRequest( + String id) { + this(Optional.empty(), id); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * Required. The ID of the webhook to delete. + * Format: `{webhook_id}` + */ + @JsonIgnore + public String id() { + return id; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public DeleteWebhookRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public DeleteWebhookRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * Required. The ID of the webhook to delete. + * Format: `{webhook_id}` + */ + public DeleteWebhookRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteWebhookRequest other = (DeleteWebhookRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.id, other.id); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, id); + } + + @Override + public String toString() { + return Utils.toString(DeleteWebhookRequest.class, + "apiVersion", apiVersion, + "id", id); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private String id; + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * Required. The ID of the webhook to delete. + * Format: `{webhook_id}` + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public DeleteWebhookRequest build() { + + return new DeleteWebhookRequest( + apiVersion, id); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookRequestBuilder.java new file mode 100644 index 00000000000..02d340c5798 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookRequestBuilder.java @@ -0,0 +1,96 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.DeleteWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class DeleteWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public DeleteWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public DeleteWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public DeleteWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public DeleteWebhookRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public DeleteWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public DeleteWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private DeleteWebhookRequest buildRequest() { + + DeleteWebhookRequest request = new DeleteWebhookRequest(apiVersion, + id); + + return request; + } + + public DeleteWebhookResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new DeleteWebhook.Sync(sdkConfiguration, options, _headers); + DeleteWebhookRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookResponse.java new file mode 100644 index 00000000000..72ae33cb796 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/DeleteWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.interactions.Empty; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class DeleteWebhookResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional empty; + + @JsonCreator + public DeleteWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional empty) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(empty, "empty"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.empty = empty; + } + + public DeleteWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional empty() { + return (Optional) empty; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public DeleteWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public DeleteWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public DeleteWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public DeleteWebhookResponse withEmpty(Empty empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = Optional.ofNullable(empty); + return this; + } + + + /** + * Successful operation + */ + public DeleteWebhookResponse withEmpty(Optional empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = empty; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteWebhookResponse other = (DeleteWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.empty, other.empty); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + empty); + } + + @Override + public String toString() { + return Utils.toString(DeleteWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "empty", empty); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional empty = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder empty(Empty empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = Optional.ofNullable(empty); + return this; + } + + /** + * Successful operation + */ + public Builder empty(Optional empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = empty; + return this; + } + + public DeleteWebhookResponse build() { + + return new DeleteWebhookResponse( + contentType, statusCode, rawResponse, + empty); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetAgentRequest.java b/src/main/java/com/google/genai/gaos/models/operations/GetAgentRequest.java new file mode 100644 index 00000000000..6d25ba5b6cc --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetAgentRequest.java @@ -0,0 +1,172 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetAgentRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + @JsonCreator + public GetAgentRequest( + Optional apiVersion, + String id) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(id, "id"); + this.apiVersion = apiVersion; + this.id = id; + } + + public GetAgentRequest( + String id) { + this(Optional.empty(), id); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + @JsonIgnore + public String id() { + return id; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public GetAgentRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public GetAgentRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public GetAgentRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetAgentRequest other = (GetAgentRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.id, other.id); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, id); + } + + @Override + public String toString() { + return Utils.toString(GetAgentRequest.class, + "apiVersion", apiVersion, + "id", id); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private String id; + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public GetAgentRequest build() { + + return new GetAgentRequest( + apiVersion, id); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetAgentRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/GetAgentRequestBuilder.java new file mode 100644 index 00000000000..4845756df0f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetAgentRequestBuilder.java @@ -0,0 +1,96 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.GetAgent; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class GetAgentRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public GetAgentRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public GetAgentRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public GetAgentRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public GetAgentRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public GetAgentRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public GetAgentRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private GetAgentRequest buildRequest() { + + GetAgentRequest request = new GetAgentRequest(apiVersion, + id); + + return request; + } + + public GetAgentResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new GetAgent.Sync(sdkConfiguration, options, _headers); + GetAgentRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetAgentResponse.java b/src/main/java/com/google/genai/gaos/models/operations/GetAgentResponse.java new file mode 100644 index 00000000000..6d87fce21a9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetAgentResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetAgentResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional agent; + + @JsonCreator + public GetAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional agent) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(agent, "agent"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.agent = agent; + } + + public GetAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional agent() { + return (Optional) agent; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public GetAgentResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public GetAgentResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public GetAgentResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public GetAgentResponse withAgent(Agent agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + + /** + * Successful operation + */ + public GetAgentResponse withAgent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetAgentResponse other = (GetAgentResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.agent, other.agent); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + agent); + } + + @Override + public String toString() { + return Utils.toString(GetAgentResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "agent", agent); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional agent = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder agent(Agent agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + /** + * Successful operation + */ + public Builder agent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + public GetAgentResponse build() { + + return new GetAgentResponse( + contentType, statusCode, rawResponse, + agent); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdRequest.java b/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdRequest.java new file mode 100644 index 00000000000..a6b58f54c6e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdRequest.java @@ -0,0 +1,410 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.utils.LazySingletonValue; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Boolean; +import java.lang.Deprecated; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetInteractionByIdRequest { + /** + * The unique identifier of the interaction to retrieve. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + /** + * If set to true, the generated content will be streamed incrementally. + */ + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=stream") + private Optional stream; + + /** + * Optional. If set, resumes the interaction stream from the next chunk after the event marked by the + * event id. Can only be used if `stream` is true. + */ + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=last_event_id") + private Optional lastEventId; + + /** + * If set to true, includes the input in the response. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=include_input") + @Deprecated + private Optional includeInput; + + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + @JsonCreator + public GetInteractionByIdRequest( + String id, + Optional stream, + Optional lastEventId, + Optional includeInput, + Optional apiVersion) { + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(stream, "stream"); + Utils.checkNotNull(lastEventId, "lastEventId"); + Utils.checkNotNull(includeInput, "includeInput"); + Utils.checkNotNull(apiVersion, "apiVersion"); + this.id = id; + this.stream = stream; + this.lastEventId = lastEventId; + this.includeInput = includeInput; + this.apiVersion = apiVersion; + } + + public GetInteractionByIdRequest( + String id) { + this(id, Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); + } + + /** + * The unique identifier of the interaction to retrieve. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * If set to true, the generated content will be streamed incrementally. + */ + @JsonIgnore + public Optional stream() { + return stream; + } + + /** + * Optional. If set, resumes the interaction stream from the next chunk after the event marked by the + * event id. Can only be used if `stream` is true. + */ + @JsonIgnore + public Optional lastEventId() { + return lastEventId; + } + + /** + * If set to true, includes the input in the response. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + @JsonIgnore + public Optional includeInput() { + return includeInput; + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The unique identifier of the interaction to retrieve. + */ + public GetInteractionByIdRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * If set to true, the generated content will be streamed incrementally. + */ + public GetInteractionByIdRequest withStream(boolean stream) { + Utils.checkNotNull(stream, "stream"); + this.stream = Optional.ofNullable(stream); + return this; + } + + + /** + * If set to true, the generated content will be streamed incrementally. + */ + public GetInteractionByIdRequest withStream(Optional stream) { + Utils.checkNotNull(stream, "stream"); + this.stream = stream; + return this; + } + + /** + * Optional. If set, resumes the interaction stream from the next chunk after the event marked by the + * event id. Can only be used if `stream` is true. + */ + public GetInteractionByIdRequest withLastEventId(String lastEventId) { + Utils.checkNotNull(lastEventId, "lastEventId"); + this.lastEventId = Optional.ofNullable(lastEventId); + return this; + } + + + /** + * Optional. If set, resumes the interaction stream from the next chunk after the event marked by the + * event id. Can only be used if `stream` is true. + */ + public GetInteractionByIdRequest withLastEventId(Optional lastEventId) { + Utils.checkNotNull(lastEventId, "lastEventId"); + this.lastEventId = lastEventId; + return this; + } + + /** + * If set to true, includes the input in the response. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public GetInteractionByIdRequest withIncludeInput(boolean includeInput) { + Utils.checkNotNull(includeInput, "includeInput"); + this.includeInput = Optional.ofNullable(includeInput); + return this; + } + + + /** + * If set to true, includes the input in the response. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public GetInteractionByIdRequest withIncludeInput(Optional includeInput) { + Utils.checkNotNull(includeInput, "includeInput"); + this.includeInput = includeInput; + return this; + } + + /** + * Which version of the API to use. + */ + public GetInteractionByIdRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public GetInteractionByIdRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetInteractionByIdRequest other = (GetInteractionByIdRequest) o; + return + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.stream, other.stream) && + Utils.enhancedDeepEquals(this.lastEventId, other.lastEventId) && + Utils.enhancedDeepEquals(this.includeInput, other.includeInput) && + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + id, stream, lastEventId, + includeInput, apiVersion); + } + + @Override + public String toString() { + return Utils.toString(GetInteractionByIdRequest.class, + "id", id, + "stream", stream, + "lastEventId", lastEventId, + "includeInput", includeInput, + "apiVersion", apiVersion); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String id; + + private Optional stream; + + private Optional lastEventId = Optional.empty(); + + @Deprecated + private Optional includeInput; + + private Optional apiVersion = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The unique identifier of the interaction to retrieve. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * If set to true, the generated content will be streamed incrementally. + */ + public Builder stream(boolean stream) { + Utils.checkNotNull(stream, "stream"); + this.stream = Optional.ofNullable(stream); + return this; + } + + /** + * If set to true, the generated content will be streamed incrementally. + */ + public Builder stream(Optional stream) { + Utils.checkNotNull(stream, "stream"); + this.stream = stream; + return this; + } + + + /** + * Optional. If set, resumes the interaction stream from the next chunk after the event marked by the + * event id. Can only be used if `stream` is true. + */ + public Builder lastEventId(String lastEventId) { + Utils.checkNotNull(lastEventId, "lastEventId"); + this.lastEventId = Optional.ofNullable(lastEventId); + return this; + } + + /** + * Optional. If set, resumes the interaction stream from the next chunk after the event marked by the + * event id. Can only be used if `stream` is true. + */ + public Builder lastEventId(Optional lastEventId) { + Utils.checkNotNull(lastEventId, "lastEventId"); + this.lastEventId = lastEventId; + return this; + } + + + /** + * If set to true, includes the input in the response. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder includeInput(boolean includeInput) { + Utils.checkNotNull(includeInput, "includeInput"); + this.includeInput = Optional.ofNullable(includeInput); + return this; + } + + /** + * If set to true, includes the input in the response. + * + * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + */ + @Deprecated + public Builder includeInput(Optional includeInput) { + Utils.checkNotNull(includeInput, "includeInput"); + this.includeInput = includeInput; + return this; + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public GetInteractionByIdRequest build() { + if (stream == null) { + stream = _SINGLETON_VALUE_Stream.value(); + } + if (includeInput == null) { + includeInput = _SINGLETON_VALUE_IncludeInput.value(); + } + + return new GetInteractionByIdRequest( + id, stream, lastEventId, + includeInput, apiVersion); + } + + + private static final LazySingletonValue> _SINGLETON_VALUE_Stream = + new LazySingletonValue<>( + "stream", + "false", + new TypeReference>() {}); + + private static final LazySingletonValue> _SINGLETON_VALUE_IncludeInput = + new LazySingletonValue<>( + "include_input", + "false", + new TypeReference>() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdRequestBuilder.java new file mode 100644 index 00000000000..c895b0a794b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdRequestBuilder.java @@ -0,0 +1,72 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.GetInteractionById; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.util.Optional; + +@SuppressWarnings("all") +public class GetInteractionByIdRequestBuilder { + + private GetInteractionByIdRequest request; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public GetInteractionByIdRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public GetInteractionByIdRequestBuilder request(GetInteractionByIdRequest request) { + Utils.checkNotNull(request, "request"); + this.request = request; + return this; + } + + public GetInteractionByIdRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public GetInteractionByIdRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + public GetInteractionByIdResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new GetInteractionById.Sync(sdkConfiguration, options, _headers); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdResponse.java b/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdResponse.java new file mode 100644 index 00000000000..72ee9e444c7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetInteractionByIdResponse.java @@ -0,0 +1,284 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.utils.EventStream; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetInteractionByIdResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful retrieval of the interaction. + */ + private Optional interaction; + + @JsonCreator + public GetInteractionByIdResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional interaction) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(interaction, "interaction"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.interaction = interaction; + } + + public GetInteractionByIdResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful retrieval of the interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional interaction() { + return (Optional) interaction; + } + // value overriden by x-speakeasy-sse-sentinel extension via reflection at runtime + private Optional _eventSentinel = Optional.empty(); + + public EventStream events() { + return new EventStream( + rawResponse.body(), + new TypeReference() {}, + Utils.mapper(), + _eventSentinel); + } + + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public GetInteractionByIdResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public GetInteractionByIdResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public GetInteractionByIdResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful retrieval of the interaction. + */ + public GetInteractionByIdResponse withInteraction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + + /** + * Successful retrieval of the interaction. + */ + public GetInteractionByIdResponse withInteraction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetInteractionByIdResponse other = (GetInteractionByIdResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.interaction, other.interaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + interaction); + } + + @Override + public String toString() { + return Utils.toString(GetInteractionByIdResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "interaction", interaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional interaction = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful retrieval of the interaction. + */ + public Builder interaction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + /** + * Successful retrieval of the interaction. + */ + public Builder interaction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + public GetInteractionByIdResponse build() { + + return new GetInteractionByIdResponse( + contentType, statusCode, rawResponse, + interaction); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetWebhookRequest.java b/src/main/java/com/google/genai/gaos/models/operations/GetWebhookRequest.java new file mode 100644 index 00000000000..7d612d5cc80 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetWebhookRequest.java @@ -0,0 +1,183 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetWebhookRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * Required. The ID of the webhook to retrieve. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + @JsonCreator + public GetWebhookRequest( + Optional apiVersion, + String id) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(id, "id"); + this.apiVersion = apiVersion; + this.id = id; + } + + public GetWebhookRequest( + String id) { + this(Optional.empty(), id); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * Required. The ID of the webhook to retrieve. + */ + @JsonIgnore + public String id() { + return id; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public GetWebhookRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public GetWebhookRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * Required. The ID of the webhook to retrieve. + */ + public GetWebhookRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetWebhookRequest other = (GetWebhookRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.id, other.id); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, id); + } + + @Override + public String toString() { + return Utils.toString(GetWebhookRequest.class, + "apiVersion", apiVersion, + "id", id); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private String id; + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * Required. The ID of the webhook to retrieve. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public GetWebhookRequest build() { + + return new GetWebhookRequest( + apiVersion, id); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/GetWebhookRequestBuilder.java new file mode 100644 index 00000000000..feed68e28ce --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetWebhookRequestBuilder.java @@ -0,0 +1,96 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.GetWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class GetWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public GetWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public GetWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public GetWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public GetWebhookRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public GetWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public GetWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private GetWebhookRequest buildRequest() { + + GetWebhookRequest request = new GetWebhookRequest(apiVersion, + id); + + return request; + } + + public GetWebhookResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new GetWebhook.Sync(sdkConfiguration, options, _headers); + GetWebhookRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/GetWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/GetWebhookResponse.java new file mode 100644 index 00000000000..ff0c1809742 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/GetWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetWebhookResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhook; + + @JsonCreator + public GetWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhook) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhook, "webhook"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhook = webhook; + } + + public GetWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhook() { + return (Optional) webhook; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public GetWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public GetWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public GetWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public GetWebhookResponse withWebhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + + /** + * Successful operation + */ + public GetWebhookResponse withWebhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetWebhookResponse other = (GetWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhook, other.webhook); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhook); + } + + @Override + public String toString() { + return Utils.toString(GetWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhook", webhook); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhook = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + /** + * Successful operation + */ + public Builder webhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + public GetWebhookResponse build() { + + return new GetWebhookResponse( + contentType, statusCode, rawResponse, + webhook); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/ListAgentsRequest.java b/src/main/java/com/google/genai/gaos/models/operations/ListAgentsRequest.java new file mode 100644 index 00000000000..3fac195ec9c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/ListAgentsRequest.java @@ -0,0 +1,272 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ListAgentsRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=page_size") + private Optional pageSize; + + + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=page_token") + private Optional pageToken; + + + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=parent") + private Optional parent; + + @JsonCreator + public ListAgentsRequest( + Optional apiVersion, + Optional pageSize, + Optional pageToken, + Optional parent) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(pageSize, "pageSize"); + Utils.checkNotNull(pageToken, "pageToken"); + Utils.checkNotNull(parent, "parent"); + this.apiVersion = apiVersion; + this.pageSize = pageSize; + this.pageToken = pageToken; + this.parent = parent; + } + + public ListAgentsRequest() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + @JsonIgnore + public Optional pageSize() { + return pageSize; + } + + @JsonIgnore + public Optional pageToken() { + return pageToken; + } + + @JsonIgnore + public Optional parent() { + return parent; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public ListAgentsRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public ListAgentsRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public ListAgentsRequest withPageSize(int pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + + public ListAgentsRequest withPageSize(Optional pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = pageSize; + return this; + } + + public ListAgentsRequest withPageToken(String pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = Optional.ofNullable(pageToken); + return this; + } + + + public ListAgentsRequest withPageToken(Optional pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = pageToken; + return this; + } + + public ListAgentsRequest withParent(String parent) { + Utils.checkNotNull(parent, "parent"); + this.parent = Optional.ofNullable(parent); + return this; + } + + + public ListAgentsRequest withParent(Optional parent) { + Utils.checkNotNull(parent, "parent"); + this.parent = parent; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListAgentsRequest other = (ListAgentsRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.pageSize, other.pageSize) && + Utils.enhancedDeepEquals(this.pageToken, other.pageToken) && + Utils.enhancedDeepEquals(this.parent, other.parent); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, pageSize, pageToken, + parent); + } + + @Override + public String toString() { + return Utils.toString(ListAgentsRequest.class, + "apiVersion", apiVersion, + "pageSize", pageSize, + "pageToken", pageToken, + "parent", parent); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + private Optional pageToken = Optional.empty(); + + private Optional parent = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + public Builder pageSize(int pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + public Builder pageSize(Optional pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = pageSize; + return this; + } + + + public Builder pageToken(String pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = Optional.ofNullable(pageToken); + return this; + } + + public Builder pageToken(Optional pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = pageToken; + return this; + } + + + public Builder parent(String parent) { + Utils.checkNotNull(parent, "parent"); + this.parent = Optional.ofNullable(parent); + return this; + } + + public Builder parent(Optional parent) { + Utils.checkNotNull(parent, "parent"); + this.parent = parent; + return this; + } + + public ListAgentsRequest build() { + + return new ListAgentsRequest( + apiVersion, pageSize, pageToken, + parent); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/ListAgentsRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/ListAgentsRequestBuilder.java new file mode 100644 index 00000000000..7fa4cae27d7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/ListAgentsRequestBuilder.java @@ -0,0 +1,131 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.ListAgents; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class ListAgentsRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private Optional pageSize = Optional.empty(); + private Optional pageToken = Optional.empty(); + private Optional parent = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public ListAgentsRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public ListAgentsRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public ListAgentsRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public ListAgentsRequestBuilder pageSize(int pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = Optional.of(pageSize); + return this; + } + + public ListAgentsRequestBuilder pageSize(Optional pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = pageSize; + return this; + } + + public ListAgentsRequestBuilder pageToken(String pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = Optional.of(pageToken); + return this; + } + + public ListAgentsRequestBuilder pageToken(Optional pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = pageToken; + return this; + } + + public ListAgentsRequestBuilder parent(String parent) { + Utils.checkNotNull(parent, "parent"); + this.parent = Optional.of(parent); + return this; + } + + public ListAgentsRequestBuilder parent(Optional parent) { + Utils.checkNotNull(parent, "parent"); + this.parent = parent; + return this; + } + + public ListAgentsRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public ListAgentsRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private ListAgentsRequest buildRequest() { + + ListAgentsRequest request = new ListAgentsRequest(apiVersion, + pageSize, + pageToken, + parent); + + return request; + } + + public ListAgentsResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new ListAgents.Sync(sdkConfiguration, options, _headers); + ListAgentsRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/ListAgentsResponse.java b/src/main/java/com/google/genai/gaos/models/operations/ListAgentsResponse.java new file mode 100644 index 00000000000..6717ab7b389 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/ListAgentsResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.agents.AgentListResponse; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ListAgentsResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional agentListResponse; + + @JsonCreator + public ListAgentsResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional agentListResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.agentListResponse = agentListResponse; + } + + public ListAgentsResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional agentListResponse() { + return (Optional) agentListResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public ListAgentsResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public ListAgentsResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public ListAgentsResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public ListAgentsResponse withAgentListResponse(AgentListResponse agentListResponse) { + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.agentListResponse = Optional.ofNullable(agentListResponse); + return this; + } + + + /** + * Successful operation + */ + public ListAgentsResponse withAgentListResponse(Optional agentListResponse) { + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.agentListResponse = agentListResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListAgentsResponse other = (ListAgentsResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.agentListResponse, other.agentListResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + agentListResponse); + } + + @Override + public String toString() { + return Utils.toString(ListAgentsResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "agentListResponse", agentListResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional agentListResponse = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder agentListResponse(AgentListResponse agentListResponse) { + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.agentListResponse = Optional.ofNullable(agentListResponse); + return this; + } + + /** + * Successful operation + */ + public Builder agentListResponse(Optional agentListResponse) { + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.agentListResponse = agentListResponse; + return this; + } + + public ListAgentsResponse build() { + + return new ListAgentsResponse( + contentType, statusCode, rawResponse, + agentListResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksRequest.java b/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksRequest.java new file mode 100644 index 00000000000..964a19f24cb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksRequest.java @@ -0,0 +1,279 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ListWebhooksRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * Optional. The maximum number of webhooks to return. The service may return fewer than + * this value. If unspecified, at most 50 webhooks will be returned. + * The maximum value is 1000. + */ + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=page_size") + private Optional pageSize; + + /** + * Optional. A page token, received from a previous `ListWebhooks` call. + * Provide this to retrieve the subsequent page. + */ + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=page_token") + private Optional pageToken; + + @JsonCreator + public ListWebhooksRequest( + Optional apiVersion, + Optional pageSize, + Optional pageToken) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(pageSize, "pageSize"); + Utils.checkNotNull(pageToken, "pageToken"); + this.apiVersion = apiVersion; + this.pageSize = pageSize; + this.pageToken = pageToken; + } + + public ListWebhooksRequest() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * Optional. The maximum number of webhooks to return. The service may return fewer than + * this value. If unspecified, at most 50 webhooks will be returned. + * The maximum value is 1000. + */ + @JsonIgnore + public Optional pageSize() { + return pageSize; + } + + /** + * Optional. A page token, received from a previous `ListWebhooks` call. + * Provide this to retrieve the subsequent page. + */ + @JsonIgnore + public Optional pageToken() { + return pageToken; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public ListWebhooksRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public ListWebhooksRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * Optional. The maximum number of webhooks to return. The service may return fewer than + * this value. If unspecified, at most 50 webhooks will be returned. + * The maximum value is 1000. + */ + public ListWebhooksRequest withPageSize(int pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + + /** + * Optional. The maximum number of webhooks to return. The service may return fewer than + * this value. If unspecified, at most 50 webhooks will be returned. + * The maximum value is 1000. + */ + public ListWebhooksRequest withPageSize(Optional pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = pageSize; + return this; + } + + /** + * Optional. A page token, received from a previous `ListWebhooks` call. + * Provide this to retrieve the subsequent page. + */ + public ListWebhooksRequest withPageToken(String pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = Optional.ofNullable(pageToken); + return this; + } + + + /** + * Optional. A page token, received from a previous `ListWebhooks` call. + * Provide this to retrieve the subsequent page. + */ + public ListWebhooksRequest withPageToken(Optional pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = pageToken; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListWebhooksRequest other = (ListWebhooksRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.pageSize, other.pageSize) && + Utils.enhancedDeepEquals(this.pageToken, other.pageToken); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, pageSize, pageToken); + } + + @Override + public String toString() { + return Utils.toString(ListWebhooksRequest.class, + "apiVersion", apiVersion, + "pageSize", pageSize, + "pageToken", pageToken); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + private Optional pageToken = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * Optional. The maximum number of webhooks to return. The service may return fewer than + * this value. If unspecified, at most 50 webhooks will be returned. + * The maximum value is 1000. + */ + public Builder pageSize(int pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + /** + * Optional. The maximum number of webhooks to return. The service may return fewer than + * this value. If unspecified, at most 50 webhooks will be returned. + * The maximum value is 1000. + */ + public Builder pageSize(Optional pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = pageSize; + return this; + } + + + /** + * Optional. A page token, received from a previous `ListWebhooks` call. + * Provide this to retrieve the subsequent page. + */ + public Builder pageToken(String pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = Optional.ofNullable(pageToken); + return this; + } + + /** + * Optional. A page token, received from a previous `ListWebhooks` call. + * Provide this to retrieve the subsequent page. + */ + public Builder pageToken(Optional pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = pageToken; + return this; + } + + public ListWebhooksRequest build() { + + return new ListWebhooksRequest( + apiVersion, pageSize, pageToken); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksRequestBuilder.java new file mode 100644 index 00000000000..77c7aef5589 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksRequestBuilder.java @@ -0,0 +1,117 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.operations.ListWebhooks; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class ListWebhooksRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private Optional pageSize = Optional.empty(); + private Optional pageToken = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public ListWebhooksRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public ListWebhooksRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public ListWebhooksRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public ListWebhooksRequestBuilder pageSize(int pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = Optional.of(pageSize); + return this; + } + + public ListWebhooksRequestBuilder pageSize(Optional pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = pageSize; + return this; + } + + public ListWebhooksRequestBuilder pageToken(String pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = Optional.of(pageToken); + return this; + } + + public ListWebhooksRequestBuilder pageToken(Optional pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = pageToken; + return this; + } + + public ListWebhooksRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public ListWebhooksRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private ListWebhooksRequest buildRequest() { + + ListWebhooksRequest request = new ListWebhooksRequest(apiVersion, + pageSize, + pageToken); + + return request; + } + + public ListWebhooksResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new ListWebhooks.Sync(sdkConfiguration, options, _headers); + ListWebhooksRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksResponse.java b/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksResponse.java new file mode 100644 index 00000000000..632189a5951 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/ListWebhooksResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.WebhookListResponse; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ListWebhooksResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhookListResponse; + + @JsonCreator + public ListWebhooksResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhookListResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhookListResponse = webhookListResponse; + } + + public ListWebhooksResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhookListResponse() { + return (Optional) webhookListResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public ListWebhooksResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public ListWebhooksResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public ListWebhooksResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public ListWebhooksResponse withWebhookListResponse(WebhookListResponse webhookListResponse) { + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.webhookListResponse = Optional.ofNullable(webhookListResponse); + return this; + } + + + /** + * Successful operation + */ + public ListWebhooksResponse withWebhookListResponse(Optional webhookListResponse) { + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.webhookListResponse = webhookListResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListWebhooksResponse other = (ListWebhooksResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhookListResponse, other.webhookListResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhookListResponse); + } + + @Override + public String toString() { + return Utils.toString(ListWebhooksResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhookListResponse", webhookListResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhookListResponse = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhookListResponse(WebhookListResponse webhookListResponse) { + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.webhookListResponse = Optional.ofNullable(webhookListResponse); + return this; + } + + /** + * Successful operation + */ + public Builder webhookListResponse(Optional webhookListResponse) { + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.webhookListResponse = webhookListResponse; + return this; + } + + public ListWebhooksResponse build() { + + return new ListWebhooksResponse( + contentType, statusCode, rawResponse, + webhookListResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/PingWebhookRequest.java b/src/main/java/com/google/genai/gaos/models/operations/PingWebhookRequest.java new file mode 100644 index 00000000000..b044e558685 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/PingWebhookRequest.java @@ -0,0 +1,248 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class PingWebhookRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * Required. The ID of the webhook to ping. + * Format: `{webhook_id}` + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + /** + * The request body. + */ + @SpeakeasyMetadata("request:mediaType=application/json") + private Optional body; + + @JsonCreator + public PingWebhookRequest( + Optional apiVersion, + String id, + Optional body) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(body, "body"); + this.apiVersion = apiVersion; + this.id = id; + this.body = body; + } + + public PingWebhookRequest( + String id) { + this(Optional.empty(), id, Optional.empty()); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * Required. The ID of the webhook to ping. + * Format: `{webhook_id}` + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * The request body. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional body() { + return (Optional) body; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public PingWebhookRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public PingWebhookRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * Required. The ID of the webhook to ping. + * Format: `{webhook_id}` + */ + public PingWebhookRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * The request body. + */ + public PingWebhookRequest withBody(com.google.genai.gaos.models.webhooks.PingWebhookRequest body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.ofNullable(body); + return this; + } + + + /** + * The request body. + */ + public PingWebhookRequest withBody(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PingWebhookRequest other = (PingWebhookRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.body, other.body); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, id, body); + } + + @Override + public String toString() { + return Utils.toString(PingWebhookRequest.class, + "apiVersion", apiVersion, + "id", id, + "body", body); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private String id; + + private Optional body = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * Required. The ID of the webhook to ping. + * Format: `{webhook_id}` + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * The request body. + */ + public Builder body(com.google.genai.gaos.models.webhooks.PingWebhookRequest body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.ofNullable(body); + return this; + } + + /** + * The request body. + */ + public Builder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public PingWebhookRequest build() { + + return new PingWebhookRequest( + apiVersion, id, body); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/PingWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/PingWebhookRequestBuilder.java new file mode 100644 index 00000000000..93c2a1722d5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/PingWebhookRequestBuilder.java @@ -0,0 +1,111 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.webhooks.PingWebhookRequest; +import com.google.genai.gaos.operations.PingWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class PingWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional body = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public PingWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public PingWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public PingWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public PingWebhookRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public PingWebhookRequestBuilder body(PingWebhookRequest body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.of(body); + return this; + } + + public PingWebhookRequestBuilder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public PingWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public PingWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private com.google.genai.gaos.models.operations.PingWebhookRequest buildRequest() { + + com.google.genai.gaos.models.operations.PingWebhookRequest request = new com.google.genai.gaos.models.operations.PingWebhookRequest(apiVersion, + id, + body); + + return request; + } + + public PingWebhookResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new PingWebhook.Sync(sdkConfiguration, options, _headers); + com.google.genai.gaos.models.operations.PingWebhookRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/PingWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/PingWebhookResponse.java new file mode 100644 index 00000000000..c9d780bf6fe --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/PingWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.WebhookPingResponse; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class PingWebhookResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhookPingResponse; + + @JsonCreator + public PingWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhookPingResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhookPingResponse = webhookPingResponse; + } + + public PingWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhookPingResponse() { + return (Optional) webhookPingResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public PingWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public PingWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public PingWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public PingWebhookResponse withWebhookPingResponse(WebhookPingResponse webhookPingResponse) { + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.webhookPingResponse = Optional.ofNullable(webhookPingResponse); + return this; + } + + + /** + * Successful operation + */ + public PingWebhookResponse withWebhookPingResponse(Optional webhookPingResponse) { + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.webhookPingResponse = webhookPingResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PingWebhookResponse other = (PingWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhookPingResponse, other.webhookPingResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhookPingResponse); + } + + @Override + public String toString() { + return Utils.toString(PingWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhookPingResponse", webhookPingResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhookPingResponse = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhookPingResponse(WebhookPingResponse webhookPingResponse) { + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.webhookPingResponse = Optional.ofNullable(webhookPingResponse); + return this; + } + + /** + * Successful operation + */ + public Builder webhookPingResponse(Optional webhookPingResponse) { + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.webhookPingResponse = webhookPingResponse; + return this; + } + + public PingWebhookResponse build() { + + return new PingWebhookResponse( + contentType, statusCode, rawResponse, + webhookPingResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretRequest.java b/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretRequest.java new file mode 100644 index 00000000000..81f797a4c19 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretRequest.java @@ -0,0 +1,248 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class RotateSigningSecretRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * Required. The ID of the webhook for which to generate a signing secret. + * Format: `{webhook_id}` + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + /** + * The request body. + */ + @SpeakeasyMetadata("request:mediaType=application/json") + private Optional body; + + @JsonCreator + public RotateSigningSecretRequest( + Optional apiVersion, + String id, + Optional body) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(body, "body"); + this.apiVersion = apiVersion; + this.id = id; + this.body = body; + } + + public RotateSigningSecretRequest( + String id) { + this(Optional.empty(), id, Optional.empty()); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * Required. The ID of the webhook for which to generate a signing secret. + * Format: `{webhook_id}` + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * The request body. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional body() { + return (Optional) body; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public RotateSigningSecretRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public RotateSigningSecretRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * Required. The ID of the webhook for which to generate a signing secret. + * Format: `{webhook_id}` + */ + public RotateSigningSecretRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * The request body. + */ + public RotateSigningSecretRequest withBody(com.google.genai.gaos.models.webhooks.RotateSigningSecretRequest body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.ofNullable(body); + return this; + } + + + /** + * The request body. + */ + public RotateSigningSecretRequest withBody(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RotateSigningSecretRequest other = (RotateSigningSecretRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.body, other.body); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, id, body); + } + + @Override + public String toString() { + return Utils.toString(RotateSigningSecretRequest.class, + "apiVersion", apiVersion, + "id", id, + "body", body); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private String id; + + private Optional body = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * Required. The ID of the webhook for which to generate a signing secret. + * Format: `{webhook_id}` + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * The request body. + */ + public Builder body(com.google.genai.gaos.models.webhooks.RotateSigningSecretRequest body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.ofNullable(body); + return this; + } + + /** + * The request body. + */ + public Builder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public RotateSigningSecretRequest build() { + + return new RotateSigningSecretRequest( + apiVersion, id, body); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretRequestBuilder.java new file mode 100644 index 00000000000..e4a8d23adbe --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretRequestBuilder.java @@ -0,0 +1,111 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.webhooks.RotateSigningSecretRequest; +import com.google.genai.gaos.operations.RotateSigningSecret; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class RotateSigningSecretRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional body = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public RotateSigningSecretRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public RotateSigningSecretRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public RotateSigningSecretRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public RotateSigningSecretRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public RotateSigningSecretRequestBuilder body(RotateSigningSecretRequest body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.of(body); + return this; + } + + public RotateSigningSecretRequestBuilder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public RotateSigningSecretRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public RotateSigningSecretRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private com.google.genai.gaos.models.operations.RotateSigningSecretRequest buildRequest() { + + com.google.genai.gaos.models.operations.RotateSigningSecretRequest request = new com.google.genai.gaos.models.operations.RotateSigningSecretRequest(apiVersion, + id, + body); + + return request; + } + + public RotateSigningSecretResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new RotateSigningSecret.Sync(sdkConfiguration, options, _headers); + com.google.genai.gaos.models.operations.RotateSigningSecretRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretResponse.java b/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretResponse.java new file mode 100644 index 00000000000..0b086959a7f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/RotateSigningSecretResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.WebhookRotateSigningSecretResponse; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class RotateSigningSecretResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhookRotateSigningSecretResponse; + + @JsonCreator + public RotateSigningSecretResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhookRotateSigningSecretResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhookRotateSigningSecretResponse = webhookRotateSigningSecretResponse; + } + + public RotateSigningSecretResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhookRotateSigningSecretResponse() { + return (Optional) webhookRotateSigningSecretResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public RotateSigningSecretResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public RotateSigningSecretResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public RotateSigningSecretResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public RotateSigningSecretResponse withWebhookRotateSigningSecretResponse(WebhookRotateSigningSecretResponse webhookRotateSigningSecretResponse) { + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.webhookRotateSigningSecretResponse = Optional.ofNullable(webhookRotateSigningSecretResponse); + return this; + } + + + /** + * Successful operation + */ + public RotateSigningSecretResponse withWebhookRotateSigningSecretResponse(Optional webhookRotateSigningSecretResponse) { + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.webhookRotateSigningSecretResponse = webhookRotateSigningSecretResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RotateSigningSecretResponse other = (RotateSigningSecretResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhookRotateSigningSecretResponse, other.webhookRotateSigningSecretResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhookRotateSigningSecretResponse); + } + + @Override + public String toString() { + return Utils.toString(RotateSigningSecretResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhookRotateSigningSecretResponse", webhookRotateSigningSecretResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhookRotateSigningSecretResponse = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhookRotateSigningSecretResponse(WebhookRotateSigningSecretResponse webhookRotateSigningSecretResponse) { + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.webhookRotateSigningSecretResponse = Optional.ofNullable(webhookRotateSigningSecretResponse); + return this; + } + + /** + * Successful operation + */ + public Builder webhookRotateSigningSecretResponse(Optional webhookRotateSigningSecretResponse) { + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.webhookRotateSigningSecretResponse = webhookRotateSigningSecretResponse; + return this; + } + + public RotateSigningSecretResponse build() { + + return new RotateSigningSecretResponse( + contentType, statusCode, rawResponse, + webhookRotateSigningSecretResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookRequest.java b/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookRequest.java new file mode 100644 index 00000000000..e9ee5581f14 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookRequest.java @@ -0,0 +1,307 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.WebhookUpdate; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + + +@SuppressWarnings("all") +public class UpdateWebhookRequest { + /** + * Which version of the API to use. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=api_version") + private Optional apiVersion; + + /** + * Required. The ID of the webhook to update. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=id") + private String id; + + /** + * Optional. The list of fields to update. + */ + @SpeakeasyMetadata("queryParam:style=form,explode=true,name=update_mask") + private Optional updateMask; + + /** + * Required. The webhook to update. + */ + @SpeakeasyMetadata("request:mediaType=application/json") + private Optional body; + + @JsonCreator + public UpdateWebhookRequest( + Optional apiVersion, + String id, + Optional updateMask, + Optional body) { + Utils.checkNotNull(apiVersion, "apiVersion"); + Utils.checkNotNull(id, "id"); + Utils.checkNotNull(updateMask, "updateMask"); + Utils.checkNotNull(body, "body"); + this.apiVersion = apiVersion; + this.id = id; + this.updateMask = updateMask; + this.body = body; + } + + public UpdateWebhookRequest( + String id) { + this(Optional.empty(), id, Optional.empty(), + Optional.empty()); + } + + /** + * Which version of the API to use. + */ + @JsonIgnore + public Optional apiVersion() { + return apiVersion; + } + + /** + * Required. The ID of the webhook to update. + */ + @JsonIgnore + public String id() { + return id; + } + + /** + * Optional. The list of fields to update. + */ + @JsonIgnore + public Optional updateMask() { + return updateMask; + } + + /** + * Required. The webhook to update. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional body() { + return (Optional) body; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Which version of the API to use. + */ + public UpdateWebhookRequest withApiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + + /** + * Which version of the API to use. + */ + public UpdateWebhookRequest withApiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + /** + * Required. The ID of the webhook to update. + */ + public UpdateWebhookRequest withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + /** + * Optional. The list of fields to update. + */ + public UpdateWebhookRequest withUpdateMask(String updateMask) { + Utils.checkNotNull(updateMask, "updateMask"); + this.updateMask = Optional.ofNullable(updateMask); + return this; + } + + + /** + * Optional. The list of fields to update. + */ + public UpdateWebhookRequest withUpdateMask(Optional updateMask) { + Utils.checkNotNull(updateMask, "updateMask"); + this.updateMask = updateMask; + return this; + } + + /** + * Required. The webhook to update. + */ + public UpdateWebhookRequest withBody(WebhookUpdate body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.ofNullable(body); + return this; + } + + + /** + * Required. The webhook to update. + */ + public UpdateWebhookRequest withBody(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateWebhookRequest other = (UpdateWebhookRequest) o; + return + Utils.enhancedDeepEquals(this.apiVersion, other.apiVersion) && + Utils.enhancedDeepEquals(this.id, other.id) && + Utils.enhancedDeepEquals(this.updateMask, other.updateMask) && + Utils.enhancedDeepEquals(this.body, other.body); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiVersion, id, updateMask, + body); + } + + @Override + public String toString() { + return Utils.toString(UpdateWebhookRequest.class, + "apiVersion", apiVersion, + "id", id, + "updateMask", updateMask, + "body", body); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiVersion = Optional.empty(); + + private String id; + + private Optional updateMask = Optional.empty(); + + private Optional body = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Which version of the API to use. + */ + public Builder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.ofNullable(apiVersion); + return this; + } + + /** + * Which version of the API to use. + */ + public Builder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + + /** + * Required. The ID of the webhook to update. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + + /** + * Optional. The list of fields to update. + */ + public Builder updateMask(String updateMask) { + Utils.checkNotNull(updateMask, "updateMask"); + this.updateMask = Optional.ofNullable(updateMask); + return this; + } + + /** + * Optional. The list of fields to update. + */ + public Builder updateMask(Optional updateMask) { + Utils.checkNotNull(updateMask, "updateMask"); + this.updateMask = updateMask; + return this; + } + + + /** + * Required. The webhook to update. + */ + public Builder body(WebhookUpdate body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.ofNullable(body); + return this; + } + + /** + * Required. The webhook to update. + */ + public Builder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public UpdateWebhookRequest build() { + + return new UpdateWebhookRequest( + apiVersion, id, updateMask, + body); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookRequestBuilder.java new file mode 100644 index 00000000000..f5916a5dda8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookRequestBuilder.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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.webhooks.WebhookUpdate; +import com.google.genai.gaos.operations.UpdateWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class UpdateWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional updateMask = Optional.empty(); + private Optional body = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public UpdateWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public UpdateWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public UpdateWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public UpdateWebhookRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public UpdateWebhookRequestBuilder updateMask(String updateMask) { + Utils.checkNotNull(updateMask, "updateMask"); + this.updateMask = Optional.of(updateMask); + return this; + } + + public UpdateWebhookRequestBuilder updateMask(Optional updateMask) { + Utils.checkNotNull(updateMask, "updateMask"); + this.updateMask = updateMask; + return this; + } + + public UpdateWebhookRequestBuilder body(WebhookUpdate body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.of(body); + return this; + } + + public UpdateWebhookRequestBuilder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public UpdateWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public UpdateWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private UpdateWebhookRequest buildRequest() { + + UpdateWebhookRequest request = new UpdateWebhookRequest(apiVersion, + id, + updateMask, + body); + + return request; + } + + public UpdateWebhookResponse call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + RequestOperation operation + = new UpdateWebhook.Sync(sdkConfiguration, options, _headers); + UpdateWebhookRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookResponse.java new file mode 100644 index 00000000000..dc0951c935c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/UpdateWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.Response; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class UpdateWebhookResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhook; + + @JsonCreator + public UpdateWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhook) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhook, "webhook"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhook = webhook; + } + + public UpdateWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhook() { + return (Optional) webhook; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public UpdateWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public UpdateWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public UpdateWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public UpdateWebhookResponse withWebhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + + /** + * Successful operation + */ + public UpdateWebhookResponse withWebhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateWebhookResponse other = (UpdateWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhook, other.webhook); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhook); + } + + @Override + public String toString() { + return Utils.toString(UpdateWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhook", webhook); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhook = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + /** + * Successful operation + */ + public Builder webhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + public UpdateWebhookResponse build() { + + return new UpdateWebhookResponse( + contentType, statusCode, rawResponse, + webhook); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/CancelInteractionByIdRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/CancelInteractionByIdRequestBuilder.java new file mode 100644 index 00000000000..1e73710528c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/CancelInteractionByIdRequestBuilder.java @@ -0,0 +1,101 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.CancelInteractionByIdRequest; +import com.google.genai.gaos.operations.CancelInteractionById; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class CancelInteractionByIdRequestBuilder { + + private String id; + private Optional apiVersion = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public CancelInteractionByIdRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public CancelInteractionByIdRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public CancelInteractionByIdRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public CancelInteractionByIdRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CancelInteractionByIdRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public CancelInteractionByIdRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private CancelInteractionByIdRequest buildRequest() { + + CancelInteractionByIdRequest request = new CancelInteractionByIdRequest(id, + apiVersion); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new CancelInteractionById.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + CancelInteractionByIdRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/CancelInteractionByIdResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/CancelInteractionByIdResponse.java new file mode 100644 index 00000000000..e60dd870bbe --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/CancelInteractionByIdResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CancelInteractionByIdResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful cancellation of the interaction. + */ + private Optional interaction; + + @JsonCreator + public CancelInteractionByIdResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional interaction) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(interaction, "interaction"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.interaction = interaction; + } + + public CancelInteractionByIdResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful cancellation of the interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional interaction() { + return (Optional) interaction; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public CancelInteractionByIdResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public CancelInteractionByIdResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public CancelInteractionByIdResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful cancellation of the interaction. + */ + public CancelInteractionByIdResponse withInteraction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + + /** + * Successful cancellation of the interaction. + */ + public CancelInteractionByIdResponse withInteraction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CancelInteractionByIdResponse other = (CancelInteractionByIdResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.interaction, other.interaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + interaction); + } + + @Override + public String toString() { + return Utils.toString(CancelInteractionByIdResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "interaction", interaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional interaction = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful cancellation of the interaction. + */ + public Builder interaction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + /** + * Successful cancellation of the interaction. + */ + public Builder interaction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + public CancelInteractionByIdResponse build() { + + return new CancelInteractionByIdResponse( + contentType, statusCode, rawResponse, + interaction); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/CreateAgentRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/CreateAgentRequestBuilder.java new file mode 100644 index 00000000000..552653fccd0 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/CreateAgentRequestBuilder.java @@ -0,0 +1,102 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.models.operations.CreateAgentRequest; +import com.google.genai.gaos.operations.CreateAgent; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class CreateAgentRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private Agent body; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public CreateAgentRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public CreateAgentRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public CreateAgentRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CreateAgentRequestBuilder body(Agent body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateAgentRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public CreateAgentRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private CreateAgentRequest buildRequest() { + + CreateAgentRequest request = new CreateAgentRequest(apiVersion, + body); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new CreateAgent.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + CreateAgentRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/CreateAgentResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/CreateAgentResponse.java new file mode 100644 index 00000000000..b02ea0eb5b7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/CreateAgentResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateAgentResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional agent; + + @JsonCreator + public CreateAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional agent) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(agent, "agent"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.agent = agent; + } + + public CreateAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional agent() { + return (Optional) agent; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public CreateAgentResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public CreateAgentResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public CreateAgentResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public CreateAgentResponse withAgent(Agent agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + + /** + * Successful operation + */ + public CreateAgentResponse withAgent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateAgentResponse other = (CreateAgentResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.agent, other.agent); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + agent); + } + + @Override + public String toString() { + return Utils.toString(CreateAgentResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "agent", agent); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional agent = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder agent(Agent agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + /** + * Successful operation + */ + public Builder agent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + public CreateAgentResponse build() { + + return new CreateAgentResponse( + contentType, statusCode, rawResponse, + agent); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/CreateInteractionRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/CreateInteractionRequestBuilder.java new file mode 100644 index 00000000000..c8413238b45 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/CreateInteractionRequestBuilder.java @@ -0,0 +1,108 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.models.operations.CreateInteractionRequest; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.gaos.operations.CreateInteraction; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import com.google.genai.gaos.utils.reactive.EventStream; +import java.lang.String; +import java.util.Optional; + +@SuppressWarnings("all") +public class CreateInteractionRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private CreateInteractionRequestBody body; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public CreateInteractionRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public CreateInteractionRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public CreateInteractionRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CreateInteractionRequestBuilder body(CreateInteractionRequestBody body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateInteractionRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public CreateInteractionRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private CreateInteractionRequest buildRequest() { + + CreateInteractionRequest request = new CreateInteractionRequest(apiVersion, + body); + + return request; + } + + public EventStream call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new CreateInteraction.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + CreateInteractionRequest request = buildRequest(); + + return EventStream.forSSE( + operation.doRequest(request).thenCompose(operation::handleResponse), + new TypeReference<>() { + }, + Utils.mapper(), + "[DONE]"); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/CreateInteractionResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/CreateInteractionResponse.java new file mode 100644 index 00000000000..9120f321f3f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/CreateInteractionResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateInteractionResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional interaction; + + @JsonCreator + public CreateInteractionResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional interaction) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(interaction, "interaction"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.interaction = interaction; + } + + public CreateInteractionResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional interaction() { + return (Optional) interaction; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public CreateInteractionResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public CreateInteractionResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public CreateInteractionResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public CreateInteractionResponse withInteraction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + + /** + * Successful operation + */ + public CreateInteractionResponse withInteraction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateInteractionResponse other = (CreateInteractionResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.interaction, other.interaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + interaction); + } + + @Override + public String toString() { + return Utils.toString(CreateInteractionResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "interaction", interaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional interaction = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder interaction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + /** + * Successful operation + */ + public Builder interaction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + public CreateInteractionResponse build() { + + return new CreateInteractionResponse( + contentType, statusCode, rawResponse, + interaction); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/CreateWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/CreateWebhookRequestBuilder.java new file mode 100644 index 00000000000..a47967c907e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/CreateWebhookRequestBuilder.java @@ -0,0 +1,102 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.CreateWebhookRequest; +import com.google.genai.gaos.models.webhooks.WebhookInput; +import com.google.genai.gaos.operations.CreateWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class CreateWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private WebhookInput body; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public CreateWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public CreateWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public CreateWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public CreateWebhookRequestBuilder body(WebhookInput body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public CreateWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public CreateWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private CreateWebhookRequest buildRequest() { + + CreateWebhookRequest request = new CreateWebhookRequest(apiVersion, + body); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new CreateWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + CreateWebhookRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/CreateWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/CreateWebhookResponse.java new file mode 100644 index 00000000000..62e287073dd --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/CreateWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class CreateWebhookResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhook; + + @JsonCreator + public CreateWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhook) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhook, "webhook"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhook = webhook; + } + + public CreateWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhook() { + return (Optional) webhook; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public CreateWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public CreateWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public CreateWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public CreateWebhookResponse withWebhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + + /** + * Successful operation + */ + public CreateWebhookResponse withWebhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateWebhookResponse other = (CreateWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhook, other.webhook); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhook); + } + + @Override + public String toString() { + return Utils.toString(CreateWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhook", webhook); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhook = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + /** + * Successful operation + */ + public Builder webhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + public CreateWebhookResponse build() { + + return new CreateWebhookResponse( + contentType, statusCode, rawResponse, + webhook); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/DeleteAgentRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteAgentRequestBuilder.java new file mode 100644 index 00000000000..7d1ff782166 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteAgentRequestBuilder.java @@ -0,0 +1,101 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.DeleteAgentRequest; +import com.google.genai.gaos.operations.DeleteAgent; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class DeleteAgentRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public DeleteAgentRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public DeleteAgentRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public DeleteAgentRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public DeleteAgentRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public DeleteAgentRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public DeleteAgentRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private DeleteAgentRequest buildRequest() { + + DeleteAgentRequest request = new DeleteAgentRequest(apiVersion, + id); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new DeleteAgent.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + DeleteAgentRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/DeleteAgentResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteAgentResponse.java new file mode 100644 index 00000000000..df3257021ff --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteAgentResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.interactions.Empty; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class DeleteAgentResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional empty; + + @JsonCreator + public DeleteAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional empty) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(empty, "empty"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.empty = empty; + } + + public DeleteAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional empty() { + return (Optional) empty; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public DeleteAgentResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public DeleteAgentResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public DeleteAgentResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public DeleteAgentResponse withEmpty(Empty empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = Optional.ofNullable(empty); + return this; + } + + + /** + * Successful operation + */ + public DeleteAgentResponse withEmpty(Optional empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = empty; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteAgentResponse other = (DeleteAgentResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.empty, other.empty); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + empty); + } + + @Override + public String toString() { + return Utils.toString(DeleteAgentResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "empty", empty); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional empty = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder empty(Empty empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = Optional.ofNullable(empty); + return this; + } + + /** + * Successful operation + */ + public Builder empty(Optional empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = empty; + return this; + } + + public DeleteAgentResponse build() { + + return new DeleteAgentResponse( + contentType, statusCode, rawResponse, + empty); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/DeleteInteractionRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteInteractionRequestBuilder.java new file mode 100644 index 00000000000..b07a8ea8061 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteInteractionRequestBuilder.java @@ -0,0 +1,101 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.DeleteInteractionRequest; +import com.google.genai.gaos.operations.DeleteInteraction; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class DeleteInteractionRequestBuilder { + + private String id; + private Optional apiVersion = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public DeleteInteractionRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public DeleteInteractionRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public DeleteInteractionRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public DeleteInteractionRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public DeleteInteractionRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public DeleteInteractionRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private DeleteInteractionRequest buildRequest() { + + DeleteInteractionRequest request = new DeleteInteractionRequest(id, + apiVersion); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new DeleteInteraction.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + DeleteInteractionRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/DeleteInteractionResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteInteractionResponse.java new file mode 100644 index 00000000000..a31e807471e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteInteractionResponse.java @@ -0,0 +1,198 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.net.http.HttpResponse; + + +@SuppressWarnings("all") +public class DeleteInteractionResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + @JsonCreator + public DeleteInteractionResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public DeleteInteractionResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public DeleteInteractionResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public DeleteInteractionResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteInteractionResponse other = (DeleteInteractionResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse); + } + + @Override + public String toString() { + return Utils.toString(DeleteInteractionResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + public DeleteInteractionResponse build() { + + return new DeleteInteractionResponse( + contentType, statusCode, rawResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/DeleteWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteWebhookRequestBuilder.java new file mode 100644 index 00000000000..2f74431081c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteWebhookRequestBuilder.java @@ -0,0 +1,101 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.DeleteWebhookRequest; +import com.google.genai.gaos.operations.DeleteWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class DeleteWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public DeleteWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public DeleteWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public DeleteWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public DeleteWebhookRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public DeleteWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public DeleteWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private DeleteWebhookRequest buildRequest() { + + DeleteWebhookRequest request = new DeleteWebhookRequest(apiVersion, + id); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new DeleteWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + DeleteWebhookRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/DeleteWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteWebhookResponse.java new file mode 100644 index 00000000000..4d8cfcb71bf --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/DeleteWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.interactions.Empty; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class DeleteWebhookResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional empty; + + @JsonCreator + public DeleteWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional empty) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(empty, "empty"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.empty = empty; + } + + public DeleteWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional empty() { + return (Optional) empty; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public DeleteWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public DeleteWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public DeleteWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public DeleteWebhookResponse withEmpty(Empty empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = Optional.ofNullable(empty); + return this; + } + + + /** + * Successful operation + */ + public DeleteWebhookResponse withEmpty(Optional empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = empty; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteWebhookResponse other = (DeleteWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.empty, other.empty); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + empty); + } + + @Override + public String toString() { + return Utils.toString(DeleteWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "empty", empty); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional empty = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder empty(Empty empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = Optional.ofNullable(empty); + return this; + } + + /** + * Successful operation + */ + public Builder empty(Optional empty) { + Utils.checkNotNull(empty, "empty"); + this.empty = empty; + return this; + } + + public DeleteWebhookResponse build() { + + return new DeleteWebhookResponse( + contentType, statusCode, rawResponse, + empty); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/GetAgentRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/GetAgentRequestBuilder.java new file mode 100644 index 00000000000..6c0baf6d2b8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/GetAgentRequestBuilder.java @@ -0,0 +1,101 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.GetAgentRequest; +import com.google.genai.gaos.operations.GetAgent; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class GetAgentRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public GetAgentRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public GetAgentRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public GetAgentRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public GetAgentRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public GetAgentRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public GetAgentRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private GetAgentRequest buildRequest() { + + GetAgentRequest request = new GetAgentRequest(apiVersion, + id); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new GetAgent.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + GetAgentRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/GetAgentResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/GetAgentResponse.java new file mode 100644 index 00000000000..b915b88253e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/GetAgentResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.agents.Agent; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetAgentResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional agent; + + @JsonCreator + public GetAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional agent) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(agent, "agent"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.agent = agent; + } + + public GetAgentResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional agent() { + return (Optional) agent; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public GetAgentResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public GetAgentResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public GetAgentResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public GetAgentResponse withAgent(Agent agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + + /** + * Successful operation + */ + public GetAgentResponse withAgent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetAgentResponse other = (GetAgentResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.agent, other.agent); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + agent); + } + + @Override + public String toString() { + return Utils.toString(GetAgentResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "agent", agent); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional agent = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder agent(Agent agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = Optional.ofNullable(agent); + return this; + } + + /** + * Successful operation + */ + public Builder agent(Optional agent) { + Utils.checkNotNull(agent, "agent"); + this.agent = agent; + return this; + } + + public GetAgentResponse build() { + + return new GetAgentResponse( + contentType, statusCode, rawResponse, + agent); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/GetInteractionByIdRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/GetInteractionByIdRequestBuilder.java new file mode 100644 index 00000000000..4a3d66d35fa --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/GetInteractionByIdRequestBuilder.java @@ -0,0 +1,83 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent; +import com.google.genai.gaos.models.operations.GetInteractionByIdRequest; +import com.google.genai.gaos.operations.GetInteractionById; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import com.google.genai.gaos.utils.reactive.EventStream; +import java.util.Optional; + +@SuppressWarnings("all") +public class GetInteractionByIdRequestBuilder { + + private GetInteractionByIdRequest request; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public GetInteractionByIdRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public GetInteractionByIdRequestBuilder request(GetInteractionByIdRequest request) { + Utils.checkNotNull(request, "request"); + this.request = request; + return this; + } + + public GetInteractionByIdRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public GetInteractionByIdRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + public EventStream call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new GetInteractionById.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + + return EventStream.forSSE( + operation.doRequest(request).thenCompose(operation::handleResponse), + new TypeReference<>() { + }, + Utils.mapper(), + "[DONE]"); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/GetInteractionByIdResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/GetInteractionByIdResponse.java new file mode 100644 index 00000000000..4e350fb3393 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/GetInteractionByIdResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetInteractionByIdResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful retrieval of the interaction. + */ + private Optional interaction; + + @JsonCreator + public GetInteractionByIdResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional interaction) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(interaction, "interaction"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.interaction = interaction; + } + + public GetInteractionByIdResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful retrieval of the interaction. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional interaction() { + return (Optional) interaction; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public GetInteractionByIdResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public GetInteractionByIdResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public GetInteractionByIdResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful retrieval of the interaction. + */ + public GetInteractionByIdResponse withInteraction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + + /** + * Successful retrieval of the interaction. + */ + public GetInteractionByIdResponse withInteraction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetInteractionByIdResponse other = (GetInteractionByIdResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.interaction, other.interaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + interaction); + } + + @Override + public String toString() { + return Utils.toString(GetInteractionByIdResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "interaction", interaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional interaction = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful retrieval of the interaction. + */ + public Builder interaction(Interaction interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = Optional.ofNullable(interaction); + return this; + } + + /** + * Successful retrieval of the interaction. + */ + public Builder interaction(Optional interaction) { + Utils.checkNotNull(interaction, "interaction"); + this.interaction = interaction; + return this; + } + + public GetInteractionByIdResponse build() { + + return new GetInteractionByIdResponse( + contentType, statusCode, rawResponse, + interaction); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/GetWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/GetWebhookRequestBuilder.java new file mode 100644 index 00000000000..6ee5819e3d8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/GetWebhookRequestBuilder.java @@ -0,0 +1,101 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.GetWebhookRequest; +import com.google.genai.gaos.operations.GetWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class GetWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public GetWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public GetWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public GetWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public GetWebhookRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public GetWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public GetWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private GetWebhookRequest buildRequest() { + + GetWebhookRequest request = new GetWebhookRequest(apiVersion, + id); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new GetWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + GetWebhookRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/GetWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/GetWebhookResponse.java new file mode 100644 index 00000000000..7f6f2ff7f11 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/GetWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class GetWebhookResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhook; + + @JsonCreator + public GetWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhook) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhook, "webhook"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhook = webhook; + } + + public GetWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhook() { + return (Optional) webhook; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public GetWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public GetWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public GetWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public GetWebhookResponse withWebhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + + /** + * Successful operation + */ + public GetWebhookResponse withWebhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetWebhookResponse other = (GetWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhook, other.webhook); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhook); + } + + @Override + public String toString() { + return Utils.toString(GetWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhook", webhook); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhook = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + /** + * Successful operation + */ + public Builder webhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + public GetWebhookResponse build() { + + return new GetWebhookResponse( + contentType, statusCode, rawResponse, + webhook); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/ListAgentsRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/ListAgentsRequestBuilder.java new file mode 100644 index 00000000000..0d230532fb9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/ListAgentsRequestBuilder.java @@ -0,0 +1,136 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.ListAgentsRequest; +import com.google.genai.gaos.operations.ListAgents; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class ListAgentsRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private Optional pageSize = Optional.empty(); + private Optional pageToken = Optional.empty(); + private Optional parent = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public ListAgentsRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public ListAgentsRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public ListAgentsRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public ListAgentsRequestBuilder pageSize(int pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = Optional.of(pageSize); + return this; + } + + public ListAgentsRequestBuilder pageSize(Optional pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = pageSize; + return this; + } + + public ListAgentsRequestBuilder pageToken(String pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = Optional.of(pageToken); + return this; + } + + public ListAgentsRequestBuilder pageToken(Optional pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = pageToken; + return this; + } + + public ListAgentsRequestBuilder parent(String parent) { + Utils.checkNotNull(parent, "parent"); + this.parent = Optional.of(parent); + return this; + } + + public ListAgentsRequestBuilder parent(Optional parent) { + Utils.checkNotNull(parent, "parent"); + this.parent = parent; + return this; + } + + public ListAgentsRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public ListAgentsRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private ListAgentsRequest buildRequest() { + + ListAgentsRequest request = new ListAgentsRequest(apiVersion, + pageSize, + pageToken, + parent); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new ListAgents.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + ListAgentsRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/ListAgentsResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/ListAgentsResponse.java new file mode 100644 index 00000000000..1aa1bbbf307 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/ListAgentsResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.agents.AgentListResponse; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ListAgentsResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional agentListResponse; + + @JsonCreator + public ListAgentsResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional agentListResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.agentListResponse = agentListResponse; + } + + public ListAgentsResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional agentListResponse() { + return (Optional) agentListResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public ListAgentsResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public ListAgentsResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public ListAgentsResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public ListAgentsResponse withAgentListResponse(AgentListResponse agentListResponse) { + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.agentListResponse = Optional.ofNullable(agentListResponse); + return this; + } + + + /** + * Successful operation + */ + public ListAgentsResponse withAgentListResponse(Optional agentListResponse) { + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.agentListResponse = agentListResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListAgentsResponse other = (ListAgentsResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.agentListResponse, other.agentListResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + agentListResponse); + } + + @Override + public String toString() { + return Utils.toString(ListAgentsResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "agentListResponse", agentListResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional agentListResponse = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder agentListResponse(AgentListResponse agentListResponse) { + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.agentListResponse = Optional.ofNullable(agentListResponse); + return this; + } + + /** + * Successful operation + */ + public Builder agentListResponse(Optional agentListResponse) { + Utils.checkNotNull(agentListResponse, "agentListResponse"); + this.agentListResponse = agentListResponse; + return this; + } + + public ListAgentsResponse build() { + + return new ListAgentsResponse( + contentType, statusCode, rawResponse, + agentListResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/ListWebhooksRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/ListWebhooksRequestBuilder.java new file mode 100644 index 00000000000..beebd679e75 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/ListWebhooksRequestBuilder.java @@ -0,0 +1,122 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.ListWebhooksRequest; +import com.google.genai.gaos.operations.ListWebhooks; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class ListWebhooksRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private Optional pageSize = Optional.empty(); + private Optional pageToken = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public ListWebhooksRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public ListWebhooksRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public ListWebhooksRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public ListWebhooksRequestBuilder pageSize(int pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = Optional.of(pageSize); + return this; + } + + public ListWebhooksRequestBuilder pageSize(Optional pageSize) { + Utils.checkNotNull(pageSize, "pageSize"); + this.pageSize = pageSize; + return this; + } + + public ListWebhooksRequestBuilder pageToken(String pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = Optional.of(pageToken); + return this; + } + + public ListWebhooksRequestBuilder pageToken(Optional pageToken) { + Utils.checkNotNull(pageToken, "pageToken"); + this.pageToken = pageToken; + return this; + } + + public ListWebhooksRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public ListWebhooksRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private ListWebhooksRequest buildRequest() { + + ListWebhooksRequest request = new ListWebhooksRequest(apiVersion, + pageSize, + pageToken); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new ListWebhooks.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + ListWebhooksRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/ListWebhooksResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/ListWebhooksResponse.java new file mode 100644 index 00000000000..87da9fbbb8b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/ListWebhooksResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.WebhookListResponse; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class ListWebhooksResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhookListResponse; + + @JsonCreator + public ListWebhooksResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhookListResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhookListResponse = webhookListResponse; + } + + public ListWebhooksResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhookListResponse() { + return (Optional) webhookListResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public ListWebhooksResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public ListWebhooksResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public ListWebhooksResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public ListWebhooksResponse withWebhookListResponse(WebhookListResponse webhookListResponse) { + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.webhookListResponse = Optional.ofNullable(webhookListResponse); + return this; + } + + + /** + * Successful operation + */ + public ListWebhooksResponse withWebhookListResponse(Optional webhookListResponse) { + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.webhookListResponse = webhookListResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListWebhooksResponse other = (ListWebhooksResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhookListResponse, other.webhookListResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhookListResponse); + } + + @Override + public String toString() { + return Utils.toString(ListWebhooksResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhookListResponse", webhookListResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhookListResponse = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhookListResponse(WebhookListResponse webhookListResponse) { + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.webhookListResponse = Optional.ofNullable(webhookListResponse); + return this; + } + + /** + * Successful operation + */ + public Builder webhookListResponse(Optional webhookListResponse) { + Utils.checkNotNull(webhookListResponse, "webhookListResponse"); + this.webhookListResponse = webhookListResponse; + return this; + } + + public ListWebhooksResponse build() { + + return new ListWebhooksResponse( + contentType, statusCode, rawResponse, + webhookListResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/PingWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/PingWebhookRequestBuilder.java new file mode 100644 index 00000000000..0d611923582 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/PingWebhookRequestBuilder.java @@ -0,0 +1,115 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.webhooks.PingWebhookRequest; +import com.google.genai.gaos.operations.PingWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class PingWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional body = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public PingWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public PingWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public PingWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public PingWebhookRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public PingWebhookRequestBuilder body(PingWebhookRequest body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.of(body); + return this; + } + + public PingWebhookRequestBuilder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public PingWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public PingWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private com.google.genai.gaos.models.operations.PingWebhookRequest buildRequest() { + + com.google.genai.gaos.models.operations.PingWebhookRequest request = new com.google.genai.gaos.models.operations.PingWebhookRequest(apiVersion, + id, + body); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new PingWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + com.google.genai.gaos.models.operations.PingWebhookRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/PingWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/PingWebhookResponse.java new file mode 100644 index 00000000000..b6119d5f2c7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/PingWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.WebhookPingResponse; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class PingWebhookResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhookPingResponse; + + @JsonCreator + public PingWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhookPingResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhookPingResponse = webhookPingResponse; + } + + public PingWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhookPingResponse() { + return (Optional) webhookPingResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public PingWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public PingWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public PingWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public PingWebhookResponse withWebhookPingResponse(WebhookPingResponse webhookPingResponse) { + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.webhookPingResponse = Optional.ofNullable(webhookPingResponse); + return this; + } + + + /** + * Successful operation + */ + public PingWebhookResponse withWebhookPingResponse(Optional webhookPingResponse) { + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.webhookPingResponse = webhookPingResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PingWebhookResponse other = (PingWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhookPingResponse, other.webhookPingResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhookPingResponse); + } + + @Override + public String toString() { + return Utils.toString(PingWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhookPingResponse", webhookPingResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhookPingResponse = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhookPingResponse(WebhookPingResponse webhookPingResponse) { + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.webhookPingResponse = Optional.ofNullable(webhookPingResponse); + return this; + } + + /** + * Successful operation + */ + public Builder webhookPingResponse(Optional webhookPingResponse) { + Utils.checkNotNull(webhookPingResponse, "webhookPingResponse"); + this.webhookPingResponse = webhookPingResponse; + return this; + } + + public PingWebhookResponse build() { + + return new PingWebhookResponse( + contentType, statusCode, rawResponse, + webhookPingResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/RotateSigningSecretRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/RotateSigningSecretRequestBuilder.java new file mode 100644 index 00000000000..4669d8d2c2d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/RotateSigningSecretRequestBuilder.java @@ -0,0 +1,115 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.webhooks.RotateSigningSecretRequest; +import com.google.genai.gaos.operations.RotateSigningSecret; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class RotateSigningSecretRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional body = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public RotateSigningSecretRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public RotateSigningSecretRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public RotateSigningSecretRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public RotateSigningSecretRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public RotateSigningSecretRequestBuilder body(RotateSigningSecretRequest body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.of(body); + return this; + } + + public RotateSigningSecretRequestBuilder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public RotateSigningSecretRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public RotateSigningSecretRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private com.google.genai.gaos.models.operations.RotateSigningSecretRequest buildRequest() { + + com.google.genai.gaos.models.operations.RotateSigningSecretRequest request = new com.google.genai.gaos.models.operations.RotateSigningSecretRequest(apiVersion, + id, + body); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new RotateSigningSecret.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + com.google.genai.gaos.models.operations.RotateSigningSecretRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/RotateSigningSecretResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/RotateSigningSecretResponse.java new file mode 100644 index 00000000000..368215942d2 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/RotateSigningSecretResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.WebhookRotateSigningSecretResponse; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class RotateSigningSecretResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhookRotateSigningSecretResponse; + + @JsonCreator + public RotateSigningSecretResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhookRotateSigningSecretResponse) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhookRotateSigningSecretResponse = webhookRotateSigningSecretResponse; + } + + public RotateSigningSecretResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhookRotateSigningSecretResponse() { + return (Optional) webhookRotateSigningSecretResponse; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public RotateSigningSecretResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public RotateSigningSecretResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public RotateSigningSecretResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public RotateSigningSecretResponse withWebhookRotateSigningSecretResponse(WebhookRotateSigningSecretResponse webhookRotateSigningSecretResponse) { + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.webhookRotateSigningSecretResponse = Optional.ofNullable(webhookRotateSigningSecretResponse); + return this; + } + + + /** + * Successful operation + */ + public RotateSigningSecretResponse withWebhookRotateSigningSecretResponse(Optional webhookRotateSigningSecretResponse) { + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.webhookRotateSigningSecretResponse = webhookRotateSigningSecretResponse; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RotateSigningSecretResponse other = (RotateSigningSecretResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhookRotateSigningSecretResponse, other.webhookRotateSigningSecretResponse); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhookRotateSigningSecretResponse); + } + + @Override + public String toString() { + return Utils.toString(RotateSigningSecretResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhookRotateSigningSecretResponse", webhookRotateSigningSecretResponse); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhookRotateSigningSecretResponse = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhookRotateSigningSecretResponse(WebhookRotateSigningSecretResponse webhookRotateSigningSecretResponse) { + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.webhookRotateSigningSecretResponse = Optional.ofNullable(webhookRotateSigningSecretResponse); + return this; + } + + /** + * Successful operation + */ + public Builder webhookRotateSigningSecretResponse(Optional webhookRotateSigningSecretResponse) { + Utils.checkNotNull(webhookRotateSigningSecretResponse, "webhookRotateSigningSecretResponse"); + this.webhookRotateSigningSecretResponse = webhookRotateSigningSecretResponse; + return this; + } + + public RotateSigningSecretResponse build() { + + return new RotateSigningSecretResponse( + contentType, statusCode, rawResponse, + webhookRotateSigningSecretResponse); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/UpdateWebhookRequestBuilder.java b/src/main/java/com/google/genai/gaos/models/operations/async/UpdateWebhookRequestBuilder.java new file mode 100644 index 00000000000..5a2b1ff2a52 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/UpdateWebhookRequestBuilder.java @@ -0,0 +1,130 @@ +/* +* 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.operations.async; + +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.UpdateWebhookRequest; +import com.google.genai.gaos.models.webhooks.WebhookUpdate; +import com.google.genai.gaos.operations.UpdateWebhook; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.lang.String; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class UpdateWebhookRequestBuilder { + + private Optional apiVersion = Optional.empty(); + private String id; + private Optional updateMask = Optional.empty(); + private Optional body = Optional.empty(); + private Optional retryConfig = Optional.empty(); + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public UpdateWebhookRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public UpdateWebhookRequestBuilder apiVersion(String apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = Optional.of(apiVersion); + return this; + } + + public UpdateWebhookRequestBuilder apiVersion(Optional apiVersion) { + Utils.checkNotNull(apiVersion, "apiVersion"); + this.apiVersion = apiVersion; + return this; + } + + public UpdateWebhookRequestBuilder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public UpdateWebhookRequestBuilder updateMask(String updateMask) { + Utils.checkNotNull(updateMask, "updateMask"); + this.updateMask = Optional.of(updateMask); + return this; + } + + public UpdateWebhookRequestBuilder updateMask(Optional updateMask) { + Utils.checkNotNull(updateMask, "updateMask"); + this.updateMask = updateMask; + return this; + } + + public UpdateWebhookRequestBuilder body(WebhookUpdate body) { + Utils.checkNotNull(body, "body"); + this.body = Optional.of(body); + return this; + } + + public UpdateWebhookRequestBuilder body(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + return this; + } + + public UpdateWebhookRequestBuilder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = Optional.of(retryConfig); + return this; + } + + public UpdateWebhookRequestBuilder retryConfig(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + + private UpdateWebhookRequest buildRequest() { + + UpdateWebhookRequest request = new UpdateWebhookRequest(apiVersion, + id, + updateMask, + body); + + return request; + } + + public CompletableFuture call() { + Optional options = Optional.of(Options.builder() + .retryConfig(retryConfig) + .build()); + + AsyncRequestOperation operation + = new UpdateWebhook.Async( + sdkConfiguration, options, sdkConfiguration.retryScheduler(), + _headers); + UpdateWebhookRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/operations/async/UpdateWebhookResponse.java b/src/main/java/com/google/genai/gaos/models/operations/async/UpdateWebhookResponse.java new file mode 100644 index 00000000000..58b7e113f39 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/operations/async/UpdateWebhookResponse.java @@ -0,0 +1,270 @@ +/* +* 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.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +@SuppressWarnings("all") +public class UpdateWebhookResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful operation + */ + private Optional webhook; + + @JsonCreator + public UpdateWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional webhook) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(webhook, "webhook"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.webhook = webhook; + } + + public UpdateWebhookResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful operation + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional webhook() { + return (Optional) webhook; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public UpdateWebhookResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public UpdateWebhookResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public UpdateWebhookResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful operation + */ + public UpdateWebhookResponse withWebhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + + /** + * Successful operation + */ + public UpdateWebhookResponse withWebhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateWebhookResponse other = (UpdateWebhookResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.webhook, other.webhook); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + webhook); + } + + @Override + public String toString() { + return Utils.toString(UpdateWebhookResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "webhook", webhook); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional webhook = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful operation + */ + public Builder webhook(Webhook webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = Optional.ofNullable(webhook); + return this; + } + + /** + * Successful operation + */ + public Builder webhook(Optional webhook) { + Utils.checkNotNull(webhook, "webhook"); + this.webhook = webhook; + return this; + } + + public UpdateWebhookResponse build() { + + return new UpdateWebhookResponse( + contentType, statusCode, rawResponse, + webhook); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/shared/Security.java b/src/main/java/com/google/genai/gaos/models/shared/Security.java new file mode 100644 index 00000000000..ed5f3c07948 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/shared/Security.java @@ -0,0 +1,273 @@ +/* +* 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.shared; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.HasSecurity; +import com.google.genai.gaos.utils.SpeakeasyMetadata; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Map; +import java.util.Optional; + + +@SuppressWarnings("all") +public class Security implements HasSecurity { + /** + * Gemini API key sent as x-goog-api-key. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("apiKey") + @SpeakeasyMetadata("security:scheme=true,type=http,subtype=custom,name=apiKey") + private Optional apiKey; + + /** + * OAuth access token sent as a bearer Authorization header. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("accessToken") + @SpeakeasyMetadata("security:scheme=true,type=http,subtype=custom,name=accessToken") + private Optional accessToken; + + /** + * Additional default headers to apply before request-specific headers and auth. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("defaultHeaders") + @SpeakeasyMetadata("security:scheme=true,type=http,subtype=custom,name=defaultHeaders") + private Optional> defaultHeaders; + + @JsonCreator + public Security( + @JsonProperty("apiKey") Optional apiKey, + @JsonProperty("accessToken") Optional accessToken, + @JsonProperty("defaultHeaders") Optional> defaultHeaders) { + Utils.checkNotNull(apiKey, "apiKey"); + Utils.checkNotNull(accessToken, "accessToken"); + Utils.checkNotNull(defaultHeaders, "defaultHeaders"); + this.apiKey = apiKey; + this.accessToken = accessToken; + this.defaultHeaders = defaultHeaders; + } + + public Security() { + this(Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * Gemini API key sent as x-goog-api-key. + */ + @JsonIgnore + public Optional apiKey() { + return apiKey; + } + + /** + * OAuth access token sent as a bearer Authorization header. + */ + @JsonIgnore + public Optional accessToken() { + return accessToken; + } + + /** + * Additional default headers to apply before request-specific headers and auth. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> defaultHeaders() { + return (Optional>) defaultHeaders; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Gemini API key sent as x-goog-api-key. + */ + public Security withApiKey(String apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = Optional.ofNullable(apiKey); + return this; + } + + + /** + * Gemini API key sent as x-goog-api-key. + */ + public Security withApiKey(Optional apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = apiKey; + return this; + } + + /** + * OAuth access token sent as a bearer Authorization header. + */ + public Security withAccessToken(String accessToken) { + Utils.checkNotNull(accessToken, "accessToken"); + this.accessToken = Optional.ofNullable(accessToken); + return this; + } + + + /** + * OAuth access token sent as a bearer Authorization header. + */ + public Security withAccessToken(Optional accessToken) { + Utils.checkNotNull(accessToken, "accessToken"); + this.accessToken = accessToken; + return this; + } + + /** + * Additional default headers to apply before request-specific headers and auth. + */ + public Security withDefaultHeaders(Map defaultHeaders) { + Utils.checkNotNull(defaultHeaders, "defaultHeaders"); + this.defaultHeaders = Optional.ofNullable(defaultHeaders); + return this; + } + + + /** + * Additional default headers to apply before request-specific headers and auth. + */ + public Security withDefaultHeaders(Optional> defaultHeaders) { + Utils.checkNotNull(defaultHeaders, "defaultHeaders"); + this.defaultHeaders = defaultHeaders; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Security other = (Security) o; + return + Utils.enhancedDeepEquals(this.apiKey, other.apiKey) && + Utils.enhancedDeepEquals(this.accessToken, other.accessToken) && + Utils.enhancedDeepEquals(this.defaultHeaders, other.defaultHeaders); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + apiKey, accessToken, defaultHeaders); + } + + @Override + public String toString() { + return Utils.toString(Security.class, + "apiKey", apiKey, + "accessToken", accessToken, + "defaultHeaders", defaultHeaders); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional apiKey = Optional.empty(); + + private Optional accessToken = Optional.empty(); + + private Optional> defaultHeaders = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Gemini API key sent as x-goog-api-key. + */ + public Builder apiKey(String apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = Optional.ofNullable(apiKey); + return this; + } + + /** + * Gemini API key sent as x-goog-api-key. + */ + public Builder apiKey(Optional apiKey) { + Utils.checkNotNull(apiKey, "apiKey"); + this.apiKey = apiKey; + return this; + } + + + /** + * OAuth access token sent as a bearer Authorization header. + */ + public Builder accessToken(String accessToken) { + Utils.checkNotNull(accessToken, "accessToken"); + this.accessToken = Optional.ofNullable(accessToken); + return this; + } + + /** + * OAuth access token sent as a bearer Authorization header. + */ + public Builder accessToken(Optional accessToken) { + Utils.checkNotNull(accessToken, "accessToken"); + this.accessToken = accessToken; + return this; + } + + + /** + * Additional default headers to apply before request-specific headers and auth. + */ + public Builder defaultHeaders(Map defaultHeaders) { + Utils.checkNotNull(defaultHeaders, "defaultHeaders"); + this.defaultHeaders = Optional.ofNullable(defaultHeaders); + return this; + } + + /** + * Additional default headers to apply before request-specific headers and auth. + */ + public Builder defaultHeaders(Optional> defaultHeaders) { + Utils.checkNotNull(defaultHeaders, "defaultHeaders"); + this.defaultHeaders = defaultHeaders; + return this; + } + + public Security build() { + + return new Security( + apiKey, accessToken, defaultHeaders); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/PingWebhookRequest.java b/src/main/java/com/google/genai/gaos/models/webhooks/PingWebhookRequest.java new file mode 100644 index 00000000000..72ef7e236b3 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/PingWebhookRequest.java @@ -0,0 +1,79 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + +/** + * PingWebhookRequest + * + *

Request message for WebhookService.PingWebhook. + */ +@SuppressWarnings("all") +public class PingWebhookRequest { + @JsonCreator + public PingWebhookRequest() { + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ); + } + + @Override + public String toString() { + return Utils.toString(PingWebhookRequest.class); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public PingWebhookRequest build() { + + return new PingWebhookRequest( + ); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/RevocationBehavior.java b/src/main/java/com/google/genai/gaos/models/webhooks/RevocationBehavior.java new file mode 100644 index 00000000000..815e47c48e5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/RevocationBehavior.java @@ -0,0 +1,57 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * RevocationBehavior + * + *

Optional. The revocation behavior for previous signing secrets. + */ +@SuppressWarnings("all") +public enum RevocationBehavior { + REVOKE_PREVIOUS_SECRETS_AFTER_H24("revoke_previous_secrets_after_h24"), + REVOKE_PREVIOUS_SECRETS_IMMEDIATELY("revoke_previous_secrets_immediately"); + + @JsonValue + private final String value; + + RevocationBehavior(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (RevocationBehavior o: RevocationBehavior.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/RotateSigningSecretRequest.java b/src/main/java/com/google/genai/gaos/models/webhooks/RotateSigningSecretRequest.java new file mode 100644 index 00000000000..e827b637ae7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/RotateSigningSecretRequest.java @@ -0,0 +1,151 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * RotateSigningSecretRequest + * + *

Request message for WebhookService.RotateSigningSecret. + */ +@SuppressWarnings("all") +public class RotateSigningSecretRequest { + /** + * Optional. The revocation behavior for previous signing secrets. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("revocation_behavior") + private Optional revocationBehavior; + + @JsonCreator + public RotateSigningSecretRequest( + @JsonProperty("revocation_behavior") Optional revocationBehavior) { + Utils.checkNotNull(revocationBehavior, "revocationBehavior"); + this.revocationBehavior = revocationBehavior; + } + + public RotateSigningSecretRequest() { + this(Optional.empty()); + } + + /** + * Optional. The revocation behavior for previous signing secrets. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional revocationBehavior() { + return (Optional) revocationBehavior; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. The revocation behavior for previous signing secrets. + */ + public RotateSigningSecretRequest withRevocationBehavior(RevocationBehavior revocationBehavior) { + Utils.checkNotNull(revocationBehavior, "revocationBehavior"); + this.revocationBehavior = Optional.ofNullable(revocationBehavior); + return this; + } + + + /** + * Optional. The revocation behavior for previous signing secrets. + */ + public RotateSigningSecretRequest withRevocationBehavior(Optional revocationBehavior) { + Utils.checkNotNull(revocationBehavior, "revocationBehavior"); + this.revocationBehavior = revocationBehavior; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RotateSigningSecretRequest other = (RotateSigningSecretRequest) o; + return + Utils.enhancedDeepEquals(this.revocationBehavior, other.revocationBehavior); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + revocationBehavior); + } + + @Override + public String toString() { + return Utils.toString(RotateSigningSecretRequest.class, + "revocationBehavior", revocationBehavior); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional revocationBehavior = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. The revocation behavior for previous signing secrets. + */ + public Builder revocationBehavior(RevocationBehavior revocationBehavior) { + Utils.checkNotNull(revocationBehavior, "revocationBehavior"); + this.revocationBehavior = Optional.ofNullable(revocationBehavior); + return this; + } + + /** + * Optional. The revocation behavior for previous signing secrets. + */ + public Builder revocationBehavior(Optional revocationBehavior) { + Utils.checkNotNull(revocationBehavior, "revocationBehavior"); + this.revocationBehavior = revocationBehavior; + return this; + } + + public RotateSigningSecretRequest build() { + + return new RotateSigningSecretRequest( + revocationBehavior); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/SigningSecret.java b/src/main/java/com/google/genai/gaos/models/webhooks/SigningSecret.java new file mode 100644 index 00000000000..e42f04f2c4f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/SigningSecret.java @@ -0,0 +1,210 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.time.OffsetDateTime; +import java.util.Optional; + +/** + * SigningSecret + * + *

Represents a signing secret used to verify webhook payloads. + */ +@SuppressWarnings("all") +public class SigningSecret { + /** + * Output only. The truncated version of the signing secret. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("truncated_secret") + private Optional truncatedSecret; + + /** + * Output only. The expiration date of the signing secret. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("expire_time") + private Optional expireTime; + + @JsonCreator + public SigningSecret( + @JsonProperty("truncated_secret") Optional truncatedSecret, + @JsonProperty("expire_time") Optional expireTime) { + Utils.checkNotNull(truncatedSecret, "truncatedSecret"); + Utils.checkNotNull(expireTime, "expireTime"); + this.truncatedSecret = truncatedSecret; + this.expireTime = expireTime; + } + + public SigningSecret() { + this(Optional.empty(), Optional.empty()); + } + + /** + * Output only. The truncated version of the signing secret. + */ + @JsonIgnore + public Optional truncatedSecret() { + return truncatedSecret; + } + + /** + * Output only. The expiration date of the signing secret. + */ + @JsonIgnore + public Optional expireTime() { + return expireTime; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Output only. The truncated version of the signing secret. + */ + public SigningSecret withTruncatedSecret(String truncatedSecret) { + Utils.checkNotNull(truncatedSecret, "truncatedSecret"); + this.truncatedSecret = Optional.ofNullable(truncatedSecret); + return this; + } + + + /** + * Output only. The truncated version of the signing secret. + */ + public SigningSecret withTruncatedSecret(Optional truncatedSecret) { + Utils.checkNotNull(truncatedSecret, "truncatedSecret"); + this.truncatedSecret = truncatedSecret; + return this; + } + + /** + * Output only. The expiration date of the signing secret. + */ + public SigningSecret withExpireTime(OffsetDateTime expireTime) { + Utils.checkNotNull(expireTime, "expireTime"); + this.expireTime = Optional.ofNullable(expireTime); + return this; + } + + + /** + * Output only. The expiration date of the signing secret. + */ + public SigningSecret withExpireTime(Optional expireTime) { + Utils.checkNotNull(expireTime, "expireTime"); + this.expireTime = expireTime; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SigningSecret other = (SigningSecret) o; + return + Utils.enhancedDeepEquals(this.truncatedSecret, other.truncatedSecret) && + Utils.enhancedDeepEquals(this.expireTime, other.expireTime); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + truncatedSecret, expireTime); + } + + @Override + public String toString() { + return Utils.toString(SigningSecret.class, + "truncatedSecret", truncatedSecret, + "expireTime", expireTime); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional truncatedSecret = Optional.empty(); + + private Optional expireTime = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Output only. The truncated version of the signing secret. + */ + public Builder truncatedSecret(String truncatedSecret) { + Utils.checkNotNull(truncatedSecret, "truncatedSecret"); + this.truncatedSecret = Optional.ofNullable(truncatedSecret); + return this; + } + + /** + * Output only. The truncated version of the signing secret. + */ + public Builder truncatedSecret(Optional truncatedSecret) { + Utils.checkNotNull(truncatedSecret, "truncatedSecret"); + this.truncatedSecret = truncatedSecret; + return this; + } + + + /** + * Output only. The expiration date of the signing secret. + */ + public Builder expireTime(OffsetDateTime expireTime) { + Utils.checkNotNull(expireTime, "expireTime"); + this.expireTime = Optional.ofNullable(expireTime); + return this; + } + + /** + * Output only. The expiration date of the signing secret. + */ + public Builder expireTime(Optional expireTime) { + Utils.checkNotNull(expireTime, "expireTime"); + this.expireTime = expireTime; + return this; + } + + public SigningSecret build() { + + return new SigningSecret( + truncatedSecret, expireTime); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/Webhook.java b/src/main/java/com/google/genai/gaos/models/webhooks/Webhook.java new file mode 100644 index 00000000000..a866f916d2f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/Webhook.java @@ -0,0 +1,634 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Optional; + +/** + * Webhook + * + *

A Webhook resource. + */ +@SuppressWarnings("all") +public class Webhook { + /** + * Optional. The user-provided name of the webhook. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + /** + * Required. The URI to which webhook events will be sent. + */ + @JsonProperty("uri") + private String uri; + + /** + * Required. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + @JsonProperty("subscribed_events") + private List subscribedEvents; + + /** + * Output only. The timestamp when the webhook was created. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("create_time") + private Optional createTime; + + /** + * Output only. The timestamp when the webhook was last updated. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("update_time") + private Optional updateTime; + + /** + * Output only. The signing secrets associated with this webhook. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("signing_secrets") + private Optional> signingSecrets; + + /** + * Output only. The state of the webhook. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("state") + private Optional state; + + /** + * Output only. The new signing secret for the webhook. Only populated on create. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("new_signing_secret") + private Optional newSigningSecret; + + /** + * Output only. The ID of the webhook. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("id") + private Optional id; + + @JsonCreator + public Webhook( + @JsonProperty("name") Optional name, + @JsonProperty("uri") String uri, + @JsonProperty("subscribed_events") List subscribedEvents, + @JsonProperty("create_time") Optional createTime, + @JsonProperty("update_time") Optional updateTime, + @JsonProperty("signing_secrets") Optional> signingSecrets, + @JsonProperty("state") Optional state, + @JsonProperty("new_signing_secret") Optional newSigningSecret, + @JsonProperty("id") Optional id) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + Utils.checkNotNull(createTime, "createTime"); + Utils.checkNotNull(updateTime, "updateTime"); + Utils.checkNotNull(signingSecrets, "signingSecrets"); + Utils.checkNotNull(state, "state"); + Utils.checkNotNull(newSigningSecret, "newSigningSecret"); + Utils.checkNotNull(id, "id"); + this.name = name; + this.uri = uri; + this.subscribedEvents = subscribedEvents; + this.createTime = createTime; + this.updateTime = updateTime; + this.signingSecrets = signingSecrets; + this.state = state; + this.newSigningSecret = newSigningSecret; + this.id = id; + } + + public Webhook( + String uri, + List subscribedEvents) { + this(Optional.empty(), uri, subscribedEvents, + Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty()); + } + + /** + * Optional. The user-provided name of the webhook. + */ + @JsonIgnore + public Optional name() { + return name; + } + + /** + * Required. The URI to which webhook events will be sent. + */ + @JsonIgnore + public String uri() { + return uri; + } + + /** + * Required. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + @JsonIgnore + public List subscribedEvents() { + return subscribedEvents; + } + + /** + * Output only. The timestamp when the webhook was created. + */ + @JsonIgnore + public Optional createTime() { + return createTime; + } + + /** + * Output only. The timestamp when the webhook was last updated. + */ + @JsonIgnore + public Optional updateTime() { + return updateTime; + } + + /** + * Output only. The signing secrets associated with this webhook. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> signingSecrets() { + return (Optional>) signingSecrets; + } + + /** + * Output only. The state of the webhook. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional state() { + return (Optional) state; + } + + /** + * Output only. The new signing secret for the webhook. Only populated on create. + */ + @JsonIgnore + public Optional newSigningSecret() { + return newSigningSecret; + } + + /** + * Output only. The ID of the webhook. + */ + @JsonIgnore + public Optional id() { + return id; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public Webhook withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public Webhook withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * Required. The URI to which webhook events will be sent. + */ + public Webhook withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + /** + * Required. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + public Webhook withSubscribedEvents(List subscribedEvents) { + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.subscribedEvents = subscribedEvents; + return this; + } + + /** + * Output only. The timestamp when the webhook was created. + */ + public Webhook withCreateTime(OffsetDateTime createTime) { + Utils.checkNotNull(createTime, "createTime"); + this.createTime = Optional.ofNullable(createTime); + return this; + } + + + /** + * Output only. The timestamp when the webhook was created. + */ + public Webhook withCreateTime(Optional createTime) { + Utils.checkNotNull(createTime, "createTime"); + this.createTime = createTime; + return this; + } + + /** + * Output only. The timestamp when the webhook was last updated. + */ + public Webhook withUpdateTime(OffsetDateTime updateTime) { + Utils.checkNotNull(updateTime, "updateTime"); + this.updateTime = Optional.ofNullable(updateTime); + return this; + } + + + /** + * Output only. The timestamp when the webhook was last updated. + */ + public Webhook withUpdateTime(Optional updateTime) { + Utils.checkNotNull(updateTime, "updateTime"); + this.updateTime = updateTime; + return this; + } + + /** + * Output only. The signing secrets associated with this webhook. + */ + public Webhook withSigningSecrets(List signingSecrets) { + Utils.checkNotNull(signingSecrets, "signingSecrets"); + this.signingSecrets = Optional.ofNullable(signingSecrets); + return this; + } + + + /** + * Output only. The signing secrets associated with this webhook. + */ + public Webhook withSigningSecrets(Optional> signingSecrets) { + Utils.checkNotNull(signingSecrets, "signingSecrets"); + this.signingSecrets = signingSecrets; + return this; + } + + /** + * Output only. The state of the webhook. + */ + public Webhook withState(WebhookState state) { + Utils.checkNotNull(state, "state"); + this.state = Optional.ofNullable(state); + return this; + } + + + /** + * Output only. The state of the webhook. + */ + public Webhook withState(Optional state) { + Utils.checkNotNull(state, "state"); + this.state = state; + return this; + } + + /** + * Output only. The new signing secret for the webhook. Only populated on create. + */ + public Webhook withNewSigningSecret(String newSigningSecret) { + Utils.checkNotNull(newSigningSecret, "newSigningSecret"); + this.newSigningSecret = Optional.ofNullable(newSigningSecret); + return this; + } + + + /** + * Output only. The new signing secret for the webhook. Only populated on create. + */ + public Webhook withNewSigningSecret(Optional newSigningSecret) { + Utils.checkNotNull(newSigningSecret, "newSigningSecret"); + this.newSigningSecret = newSigningSecret; + return this; + } + + /** + * Output only. The ID of the webhook. + */ + public Webhook withId(String id) { + Utils.checkNotNull(id, "id"); + this.id = Optional.ofNullable(id); + return this; + } + + + /** + * Output only. The ID of the webhook. + */ + public Webhook withId(Optional id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Webhook other = (Webhook) o; + return + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.subscribedEvents, other.subscribedEvents) && + Utils.enhancedDeepEquals(this.createTime, other.createTime) && + Utils.enhancedDeepEquals(this.updateTime, other.updateTime) && + Utils.enhancedDeepEquals(this.signingSecrets, other.signingSecrets) && + Utils.enhancedDeepEquals(this.state, other.state) && + Utils.enhancedDeepEquals(this.newSigningSecret, other.newSigningSecret) && + Utils.enhancedDeepEquals(this.id, other.id); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + name, uri, subscribedEvents, + createTime, updateTime, signingSecrets, + state, newSigningSecret, id); + } + + @Override + public String toString() { + return Utils.toString(Webhook.class, + "name", name, + "uri", uri, + "subscribedEvents", subscribedEvents, + "createTime", createTime, + "updateTime", updateTime, + "signingSecrets", signingSecrets, + "state", state, + "newSigningSecret", newSigningSecret, + "id", id); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional name = Optional.empty(); + + private String uri; + + private List subscribedEvents; + + private Optional createTime = Optional.empty(); + + private Optional updateTime = Optional.empty(); + + private Optional> signingSecrets = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional newSigningSecret = Optional.empty(); + + private Optional id = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + /** + * Optional. The user-provided name of the webhook. + */ + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * Required. The URI to which webhook events will be sent. + */ + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + /** + * Required. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + public Builder subscribedEvents(List subscribedEvents) { + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.subscribedEvents = subscribedEvents; + return this; + } + + + /** + * Output only. The timestamp when the webhook was created. + */ + public Builder createTime(OffsetDateTime createTime) { + Utils.checkNotNull(createTime, "createTime"); + this.createTime = Optional.ofNullable(createTime); + return this; + } + + /** + * Output only. The timestamp when the webhook was created. + */ + public Builder createTime(Optional createTime) { + Utils.checkNotNull(createTime, "createTime"); + this.createTime = createTime; + return this; + } + + + /** + * Output only. The timestamp when the webhook was last updated. + */ + public Builder updateTime(OffsetDateTime updateTime) { + Utils.checkNotNull(updateTime, "updateTime"); + this.updateTime = Optional.ofNullable(updateTime); + return this; + } + + /** + * Output only. The timestamp when the webhook was last updated. + */ + public Builder updateTime(Optional updateTime) { + Utils.checkNotNull(updateTime, "updateTime"); + this.updateTime = updateTime; + return this; + } + + + /** + * Output only. The signing secrets associated with this webhook. + */ + public Builder signingSecrets(List signingSecrets) { + Utils.checkNotNull(signingSecrets, "signingSecrets"); + this.signingSecrets = Optional.ofNullable(signingSecrets); + return this; + } + + /** + * Output only. The signing secrets associated with this webhook. + */ + public Builder signingSecrets(Optional> signingSecrets) { + Utils.checkNotNull(signingSecrets, "signingSecrets"); + this.signingSecrets = signingSecrets; + return this; + } + + + /** + * Output only. The state of the webhook. + */ + public Builder state(WebhookState state) { + Utils.checkNotNull(state, "state"); + this.state = Optional.ofNullable(state); + return this; + } + + /** + * Output only. The state of the webhook. + */ + public Builder state(Optional state) { + Utils.checkNotNull(state, "state"); + this.state = state; + return this; + } + + + /** + * Output only. The new signing secret for the webhook. Only populated on create. + */ + public Builder newSigningSecret(String newSigningSecret) { + Utils.checkNotNull(newSigningSecret, "newSigningSecret"); + this.newSigningSecret = Optional.ofNullable(newSigningSecret); + return this; + } + + /** + * Output only. The new signing secret for the webhook. Only populated on create. + */ + public Builder newSigningSecret(Optional newSigningSecret) { + Utils.checkNotNull(newSigningSecret, "newSigningSecret"); + this.newSigningSecret = newSigningSecret; + return this; + } + + + /** + * Output only. The ID of the webhook. + */ + public Builder id(String id) { + Utils.checkNotNull(id, "id"); + this.id = Optional.ofNullable(id); + return this; + } + + /** + * Output only. The ID of the webhook. + */ + public Builder id(Optional id) { + Utils.checkNotNull(id, "id"); + this.id = id; + return this; + } + + public Webhook build() { + + return new Webhook( + name, uri, subscribedEvents, + createTime, updateTime, signingSecrets, + state, newSigningSecret, id); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookInput.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookInput.java new file mode 100644 index 00000000000..a17a0a6503a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookInput.java @@ -0,0 +1,264 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + +/** + * WebhookInput + * + *

A Webhook resource. + */ +@SuppressWarnings("all") +public class WebhookInput { + /** + * Optional. The user-provided name of the webhook. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + /** + * Required. The URI to which webhook events will be sent. + */ + @JsonProperty("uri") + private String uri; + + /** + * Required. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + @JsonProperty("subscribed_events") + private List subscribedEvents; + + @JsonCreator + public WebhookInput( + @JsonProperty("name") Optional name, + @JsonProperty("uri") String uri, + @JsonProperty("subscribed_events") List subscribedEvents) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.name = name; + this.uri = uri; + this.subscribedEvents = subscribedEvents; + } + + public WebhookInput( + String uri, + List subscribedEvents) { + this(Optional.empty(), uri, subscribedEvents); + } + + /** + * Optional. The user-provided name of the webhook. + */ + @JsonIgnore + public Optional name() { + return name; + } + + /** + * Required. The URI to which webhook events will be sent. + */ + @JsonIgnore + public String uri() { + return uri; + } + + /** + * Required. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + @JsonIgnore + public List subscribedEvents() { + return subscribedEvents; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public WebhookInput withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public WebhookInput withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * Required. The URI to which webhook events will be sent. + */ + public WebhookInput withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + /** + * Required. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + public WebhookInput withSubscribedEvents(List subscribedEvents) { + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.subscribedEvents = subscribedEvents; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookInput other = (WebhookInput) o; + return + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.subscribedEvents, other.subscribedEvents); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + name, uri, subscribedEvents); + } + + @Override + public String toString() { + return Utils.toString(WebhookInput.class, + "name", name, + "uri", uri, + "subscribedEvents", subscribedEvents); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional name = Optional.empty(); + + private String uri; + + private List subscribedEvents; + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + /** + * Optional. The user-provided name of the webhook. + */ + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * Required. The URI to which webhook events will be sent. + */ + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + /** + * Required. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + public Builder subscribedEvents(List subscribedEvents) { + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.subscribedEvents = subscribedEvents; + return this; + } + + public WebhookInput build() { + + return new WebhookInput( + name, uri, subscribedEvents); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookListResponse.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookListResponse.java new file mode 100644 index 00000000000..cf75bf5e075 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookListResponse.java @@ -0,0 +1,218 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + +/** + * WebhookListResponse + * + *

Response message for WebhookService.ListWebhooks. + */ +@SuppressWarnings("all") +public class WebhookListResponse { + /** + * The webhooks. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("webhooks") + private Optional> webhooks; + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("next_page_token") + private Optional nextPageToken; + + @JsonCreator + public WebhookListResponse( + @JsonProperty("webhooks") Optional> webhooks, + @JsonProperty("next_page_token") Optional nextPageToken) { + Utils.checkNotNull(webhooks, "webhooks"); + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.webhooks = webhooks; + this.nextPageToken = nextPageToken; + } + + public WebhookListResponse() { + this(Optional.empty(), Optional.empty()); + } + + /** + * The webhooks. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> webhooks() { + return (Optional>) webhooks; + } + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + @JsonIgnore + public Optional nextPageToken() { + return nextPageToken; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The webhooks. + */ + public WebhookListResponse withWebhooks(List webhooks) { + Utils.checkNotNull(webhooks, "webhooks"); + this.webhooks = Optional.ofNullable(webhooks); + return this; + } + + + /** + * The webhooks. + */ + public WebhookListResponse withWebhooks(Optional> webhooks) { + Utils.checkNotNull(webhooks, "webhooks"); + this.webhooks = webhooks; + return this; + } + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + public WebhookListResponse withNextPageToken(String nextPageToken) { + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.nextPageToken = Optional.ofNullable(nextPageToken); + return this; + } + + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + public WebhookListResponse withNextPageToken(Optional nextPageToken) { + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.nextPageToken = nextPageToken; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookListResponse other = (WebhookListResponse) o; + return + Utils.enhancedDeepEquals(this.webhooks, other.webhooks) && + Utils.enhancedDeepEquals(this.nextPageToken, other.nextPageToken); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + webhooks, nextPageToken); + } + + @Override + public String toString() { + return Utils.toString(WebhookListResponse.class, + "webhooks", webhooks, + "nextPageToken", nextPageToken); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional> webhooks = Optional.empty(); + + private Optional nextPageToken = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The webhooks. + */ + public Builder webhooks(List webhooks) { + Utils.checkNotNull(webhooks, "webhooks"); + this.webhooks = Optional.ofNullable(webhooks); + return this; + } + + /** + * The webhooks. + */ + public Builder webhooks(Optional> webhooks) { + Utils.checkNotNull(webhooks, "webhooks"); + this.webhooks = webhooks; + return this; + } + + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + public Builder nextPageToken(String nextPageToken) { + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.nextPageToken = Optional.ofNullable(nextPageToken); + return this; + } + + /** + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + public Builder nextPageToken(Optional nextPageToken) { + Utils.checkNotNull(nextPageToken, "nextPageToken"); + this.nextPageToken = nextPageToken; + return this; + } + + public WebhookListResponse build() { + + return new WebhookListResponse( + webhooks, nextPageToken); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookPingResponse.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookPingResponse.java new file mode 100644 index 00000000000..95913406df7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookPingResponse.java @@ -0,0 +1,79 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; + +/** + * WebhookPingResponse + * + *

Response message for WebhookService.PingWebhook. + */ +@SuppressWarnings("all") +public class WebhookPingResponse { + @JsonCreator + public WebhookPingResponse() { + } + + public static Builder builder() { + return new Builder(); + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + ); + } + + @Override + public String toString() { + return Utils.toString(WebhookPingResponse.class); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Builder() { + // force use of static builder() method + } + + public WebhookPingResponse build() { + + return new WebhookPingResponse( + ); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookRotateSigningSecretResponse.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookRotateSigningSecretResponse.java new file mode 100644 index 00000000000..9aa96c32cb7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookRotateSigningSecretResponse.java @@ -0,0 +1,149 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.util.Optional; + +/** + * WebhookRotateSigningSecretResponse + * + *

Response message for WebhookService.RotateSigningSecret. + */ +@SuppressWarnings("all") +public class WebhookRotateSigningSecretResponse { + /** + * Output only. The newly generated signing secret. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("secret") + private Optional secret; + + @JsonCreator + public WebhookRotateSigningSecretResponse( + @JsonProperty("secret") Optional secret) { + Utils.checkNotNull(secret, "secret"); + this.secret = secret; + } + + public WebhookRotateSigningSecretResponse() { + this(Optional.empty()); + } + + /** + * Output only. The newly generated signing secret. + */ + @JsonIgnore + public Optional secret() { + return secret; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Output only. The newly generated signing secret. + */ + public WebhookRotateSigningSecretResponse withSecret(String secret) { + Utils.checkNotNull(secret, "secret"); + this.secret = Optional.ofNullable(secret); + return this; + } + + + /** + * Output only. The newly generated signing secret. + */ + public WebhookRotateSigningSecretResponse withSecret(Optional secret) { + Utils.checkNotNull(secret, "secret"); + this.secret = secret; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookRotateSigningSecretResponse other = (WebhookRotateSigningSecretResponse) o; + return + Utils.enhancedDeepEquals(this.secret, other.secret); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + secret); + } + + @Override + public String toString() { + return Utils.toString(WebhookRotateSigningSecretResponse.class, + "secret", secret); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional secret = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Output only. The newly generated signing secret. + */ + public Builder secret(String secret) { + Utils.checkNotNull(secret, "secret"); + this.secret = Optional.ofNullable(secret); + return this; + } + + /** + * Output only. The newly generated signing secret. + */ + public Builder secret(Optional secret) { + Utils.checkNotNull(secret, "secret"); + this.secret = secret; + return this; + } + + public WebhookRotateSigningSecretResponse build() { + + return new WebhookRotateSigningSecretResponse( + secret); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookState.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookState.java new file mode 100644 index 00000000000..f464efe4518 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookState.java @@ -0,0 +1,58 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * WebhookState + * + *

Output only. The state of the webhook. + */ +@SuppressWarnings("all") +public enum WebhookState { + ENABLED("enabled"), + DISABLED("disabled"), + DISABLED_DUE_TO_FAILED_DELIVERIES("disabled_due_to_failed_deliveries"); + + @JsonValue + private final String value; + + WebhookState(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (WebhookState o: WebhookState.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookSubscribedEvent.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookSubscribedEvent.java new file mode 100644 index 00000000000..f105163e962 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookSubscribedEvent.java @@ -0,0 +1,164 @@ +/* +* 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.webhooks; + +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. + */ +@SuppressWarnings("all") +public class WebhookSubscribedEvent { + + public static final WebhookSubscribedEvent BATCH_SUCCEEDED = new WebhookSubscribedEvent("batch.succeeded"); + public static final WebhookSubscribedEvent BATCH_EXPIRED = new WebhookSubscribedEvent("batch.expired"); + public static final WebhookSubscribedEvent BATCH_FAILED = new WebhookSubscribedEvent("batch.failed"); + public static final WebhookSubscribedEvent INTERACTION_REQUIRES_ACTION = new WebhookSubscribedEvent("interaction.requires_action"); + public static final WebhookSubscribedEvent INTERACTION_COMPLETED = new WebhookSubscribedEvent("interaction.completed"); + public static final WebhookSubscribedEvent INTERACTION_FAILED = new WebhookSubscribedEvent("interaction.failed"); + public static final WebhookSubscribedEvent VIDEO_GENERATED = new WebhookSubscribedEvent("video.generated"); + + // 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 WebhookSubscribedEvent(String value) { + this.value = value; + } + + /** + * Returns a WebhookSubscribedEvent 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 WebhookSubscribedEvent + */ + @JsonCreator + public static WebhookSubscribedEvent of(String value) { + synchronized (WebhookSubscribedEvent.class) { + return values.computeIfAbsent(value, v -> new WebhookSubscribedEvent(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; + WebhookSubscribedEvent other = (WebhookSubscribedEvent) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "WebhookSubscribedEvent [value=" + value + "]"; + } + + // return an array just like an enum + public static WebhookSubscribedEvent[] values() { + synchronized (WebhookSubscribedEvent.class) { + return values.values().toArray(new WebhookSubscribedEvent[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("batch.succeeded", BATCH_SUCCEEDED); + map.put("batch.expired", BATCH_EXPIRED); + map.put("batch.failed", BATCH_FAILED); + map.put("interaction.requires_action", INTERACTION_REQUIRES_ACTION); + map.put("interaction.completed", INTERACTION_COMPLETED); + map.put("interaction.failed", INTERACTION_FAILED); + map.put("video.generated", VIDEO_GENERATED); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("batch.succeeded", WebhookSubscribedEventEnum.BATCH_SUCCEEDED); + map.put("batch.expired", WebhookSubscribedEventEnum.BATCH_EXPIRED); + map.put("batch.failed", WebhookSubscribedEventEnum.BATCH_FAILED); + map.put("interaction.requires_action", WebhookSubscribedEventEnum.INTERACTION_REQUIRES_ACTION); + map.put("interaction.completed", WebhookSubscribedEventEnum.INTERACTION_COMPLETED); + map.put("interaction.failed", WebhookSubscribedEventEnum.INTERACTION_FAILED); + map.put("video.generated", WebhookSubscribedEventEnum.VIDEO_GENERATED); + return map; + } + + + public enum WebhookSubscribedEventEnum { + + BATCH_SUCCEEDED("batch.succeeded"), + BATCH_EXPIRED("batch.expired"), + BATCH_FAILED("batch.failed"), + INTERACTION_REQUIRES_ACTION("interaction.requires_action"), + INTERACTION_COMPLETED("interaction.completed"), + INTERACTION_FAILED("interaction.failed"), + VIDEO_GENERATED("video.generated"),; + + private final String value; + + private WebhookSubscribedEventEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdate.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdate.java new file mode 100644 index 00000000000..f4379acaff0 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdate.java @@ -0,0 +1,380 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.List; +import java.util.Optional; + + +@SuppressWarnings("all") +public class WebhookUpdate { + /** + * Optional. The user-provided name of the webhook. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("name") + private Optional name; + + /** + * Optional. The URI to which webhook events will be sent. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("uri") + private Optional uri; + + /** + * Optional. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("subscribed_events") + private Optional> subscribedEvents; + + /** + * Optional. The state of the webhook. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("state") + private Optional state; + + @JsonCreator + public WebhookUpdate( + @JsonProperty("name") Optional name, + @JsonProperty("uri") Optional uri, + @JsonProperty("subscribed_events") Optional> subscribedEvents, + @JsonProperty("state") Optional state) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(uri, "uri"); + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + Utils.checkNotNull(state, "state"); + this.name = name; + this.uri = uri; + this.subscribedEvents = subscribedEvents; + this.state = state; + } + + public WebhookUpdate() { + this(Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty()); + } + + /** + * Optional. The user-provided name of the webhook. + */ + @JsonIgnore + public Optional name() { + return name; + } + + /** + * Optional. The URI to which webhook events will be sent. + */ + @JsonIgnore + public Optional uri() { + return uri; + } + + /** + * Optional. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional> subscribedEvents() { + return (Optional>) subscribedEvents; + } + + /** + * Optional. The state of the webhook. + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional state() { + return (Optional) state; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public WebhookUpdate withName(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public WebhookUpdate withName(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + /** + * Optional. The URI to which webhook events will be sent. + */ + public WebhookUpdate withUri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + + /** + * Optional. The URI to which webhook events will be sent. + */ + public WebhookUpdate withUri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + /** + * Optional. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + public WebhookUpdate withSubscribedEvents(List subscribedEvents) { + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.subscribedEvents = Optional.ofNullable(subscribedEvents); + return this; + } + + + /** + * Optional. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + public WebhookUpdate withSubscribedEvents(Optional> subscribedEvents) { + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.subscribedEvents = subscribedEvents; + return this; + } + + /** + * Optional. The state of the webhook. + */ + public WebhookUpdate withState(WebhookUpdateState state) { + Utils.checkNotNull(state, "state"); + this.state = Optional.ofNullable(state); + return this; + } + + + /** + * Optional. The state of the webhook. + */ + public WebhookUpdate withState(Optional state) { + Utils.checkNotNull(state, "state"); + this.state = state; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhookUpdate other = (WebhookUpdate) o; + return + Utils.enhancedDeepEquals(this.name, other.name) && + Utils.enhancedDeepEquals(this.uri, other.uri) && + Utils.enhancedDeepEquals(this.subscribedEvents, other.subscribedEvents) && + Utils.enhancedDeepEquals(this.state, other.state); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + name, uri, subscribedEvents, + state); + } + + @Override + public String toString() { + return Utils.toString(WebhookUpdate.class, + "name", name, + "uri", uri, + "subscribedEvents", subscribedEvents, + "state", state); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Optional name = Optional.empty(); + + private Optional uri = Optional.empty(); + + private Optional> subscribedEvents = Optional.empty(); + + private Optional state = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * Optional. The user-provided name of the webhook. + */ + public Builder name(String name) { + Utils.checkNotNull(name, "name"); + this.name = Optional.ofNullable(name); + return this; + } + + /** + * Optional. The user-provided name of the webhook. + */ + public Builder name(Optional name) { + Utils.checkNotNull(name, "name"); + this.name = name; + return this; + } + + + /** + * Optional. The URI to which webhook events will be sent. + */ + public Builder uri(String uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = Optional.ofNullable(uri); + return this; + } + + /** + * Optional. The URI to which webhook events will be sent. + */ + public Builder uri(Optional uri) { + Utils.checkNotNull(uri, "uri"); + this.uri = uri; + return this; + } + + + /** + * Optional. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + public Builder subscribedEvents(List subscribedEvents) { + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.subscribedEvents = Optional.ofNullable(subscribedEvents); + return this; + } + + /** + * Optional. The events that the webhook is subscribed to. + * Available events: + * - batch.succeeded + * - batch.expired + * - batch.failed + * - interaction.requires_action + * - interaction.completed + * - interaction.failed + * - video.generated + */ + public Builder subscribedEvents(Optional> subscribedEvents) { + Utils.checkNotNull(subscribedEvents, "subscribedEvents"); + this.subscribedEvents = subscribedEvents; + return this; + } + + + /** + * Optional. The state of the webhook. + */ + public Builder state(WebhookUpdateState state) { + Utils.checkNotNull(state, "state"); + this.state = Optional.ofNullable(state); + return this; + } + + /** + * Optional. The state of the webhook. + */ + public Builder state(Optional state) { + Utils.checkNotNull(state, "state"); + this.state = state; + return this; + } + + public WebhookUpdate build() { + + return new WebhookUpdate( + name, uri, subscribedEvents, + state); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdateState.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdateState.java new file mode 100644 index 00000000000..96a67f5cf1a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdateState.java @@ -0,0 +1,58 @@ +/* +* 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.webhooks; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.String; +import java.util.Objects; +import java.util.Optional; + +/** + * WebhookUpdateState + * + *

Optional. The state of the webhook. + */ +@SuppressWarnings("all") +public enum WebhookUpdateState { + ENABLED("enabled"), + DISABLED("disabled"), + DISABLED_DUE_TO_FAILED_DELIVERIES("disabled_due_to_failed_deliveries"); + + @JsonValue + private final String value; + + WebhookUpdateState(String value) { + this.value = value; + } + + public String value() { + return value; + } + + public static Optional fromValue(String value) { + for (WebhookUpdateState o: WebhookUpdateState.values()) { + if (Objects.deepEquals(o.value, value)) { + return Optional.of(o); + } + } + return Optional.empty(); + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdateSubscribedEvent.java b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdateSubscribedEvent.java new file mode 100644 index 00000000000..77d9eeae4ed --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/webhooks/WebhookUpdateSubscribedEvent.java @@ -0,0 +1,164 @@ +/* +* 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.webhooks; + +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. + */ +@SuppressWarnings("all") +public class WebhookUpdateSubscribedEvent { + + public static final WebhookUpdateSubscribedEvent BATCH_SUCCEEDED = new WebhookUpdateSubscribedEvent("batch.succeeded"); + public static final WebhookUpdateSubscribedEvent BATCH_EXPIRED = new WebhookUpdateSubscribedEvent("batch.expired"); + public static final WebhookUpdateSubscribedEvent BATCH_FAILED = new WebhookUpdateSubscribedEvent("batch.failed"); + public static final WebhookUpdateSubscribedEvent INTERACTION_REQUIRES_ACTION = new WebhookUpdateSubscribedEvent("interaction.requires_action"); + public static final WebhookUpdateSubscribedEvent INTERACTION_COMPLETED = new WebhookUpdateSubscribedEvent("interaction.completed"); + public static final WebhookUpdateSubscribedEvent INTERACTION_FAILED = new WebhookUpdateSubscribedEvent("interaction.failed"); + public static final WebhookUpdateSubscribedEvent VIDEO_GENERATED = new WebhookUpdateSubscribedEvent("video.generated"); + + // 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 WebhookUpdateSubscribedEvent(String value) { + this.value = value; + } + + /** + * Returns a WebhookUpdateSubscribedEvent 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 WebhookUpdateSubscribedEvent + */ + @JsonCreator + public static WebhookUpdateSubscribedEvent of(String value) { + synchronized (WebhookUpdateSubscribedEvent.class) { + return values.computeIfAbsent(value, v -> new WebhookUpdateSubscribedEvent(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; + WebhookUpdateSubscribedEvent other = (WebhookUpdateSubscribedEvent) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "WebhookUpdateSubscribedEvent [value=" + value + "]"; + } + + // return an array just like an enum + public static WebhookUpdateSubscribedEvent[] values() { + synchronized (WebhookUpdateSubscribedEvent.class) { + return values.values().toArray(new WebhookUpdateSubscribedEvent[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("batch.succeeded", BATCH_SUCCEEDED); + map.put("batch.expired", BATCH_EXPIRED); + map.put("batch.failed", BATCH_FAILED); + map.put("interaction.requires_action", INTERACTION_REQUIRES_ACTION); + map.put("interaction.completed", INTERACTION_COMPLETED); + map.put("interaction.failed", INTERACTION_FAILED); + map.put("video.generated", VIDEO_GENERATED); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("batch.succeeded", WebhookUpdateSubscribedEventEnum.BATCH_SUCCEEDED); + map.put("batch.expired", WebhookUpdateSubscribedEventEnum.BATCH_EXPIRED); + map.put("batch.failed", WebhookUpdateSubscribedEventEnum.BATCH_FAILED); + map.put("interaction.requires_action", WebhookUpdateSubscribedEventEnum.INTERACTION_REQUIRES_ACTION); + map.put("interaction.completed", WebhookUpdateSubscribedEventEnum.INTERACTION_COMPLETED); + map.put("interaction.failed", WebhookUpdateSubscribedEventEnum.INTERACTION_FAILED); + map.put("video.generated", WebhookUpdateSubscribedEventEnum.VIDEO_GENERATED); + return map; + } + + + public enum WebhookUpdateSubscribedEventEnum { + + BATCH_SUCCEEDED("batch.succeeded"), + BATCH_EXPIRED("batch.expired"), + BATCH_FAILED("batch.failed"), + INTERACTION_REQUIRES_ACTION("interaction.requires_action"), + INTERACTION_COMPLETED("interaction.completed"), + INTERACTION_FAILED("interaction.failed"), + VIDEO_GENERATED("video.generated"),; + + private final String value; + + private WebhookUpdateSubscribedEventEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } +} + diff --git a/src/main/java/com/google/genai/gaos/operations/CancelInteractionById.java b/src/main/java/com/google/genai/gaos/operations/CancelInteractionById.java new file mode 100644 index 00000000000..5763697306b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/CancelInteractionById.java @@ -0,0 +1,333 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.CancelInteractionByIdClientError; +import com.google.genai.gaos.models.errors.CancelInteractionByIdServerError; +import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.operations.CancelInteractionByIdRequest; +import com.google.genai.gaos.models.operations.CancelInteractionByIdResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class CancelInteractionById { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "cancelInteractionById", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "cancelInteractionById", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "cancelInteractionById", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/interactions/{id}/cancel", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "POST"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(CancelInteractionByIdRequest request) throws Exception { + HttpRequest req = buildRequest(request, CancelInteractionByIdRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(CancelInteractionByIdRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public CancelInteractionByIdResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + CancelInteractionByIdResponse.Builder resBuilder = + CancelInteractionByIdResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + CancelInteractionByIdResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return res.withInteraction(Utils.unmarshal(response, new TypeReference() {})); + } else { + throw SDKException.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); + } + } + 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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(CancelInteractionByIdRequest request) throws Exception { + HttpRequest req = buildRequest(request, CancelInteractionByIdRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(CancelInteractionByIdRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.CancelInteractionByIdResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.CancelInteractionByIdResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.CancelInteractionByIdResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withInteraction); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return CancelInteractionByIdClientError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return CancelInteractionByIdServerError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/CreateAgent.java b/src/main/java/com/google/genai/gaos/operations/CreateAgent.java new file mode 100644 index 00000000000..82f9d9b66c7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/CreateAgent.java @@ -0,0 +1,334 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.agents.Agent; +import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.operations.CreateAgentRequest; +import com.google.genai.gaos.models.operations.CreateAgentResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.SerializedBody; +import com.google.genai.gaos.utils.Utils.JsonShape; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.IllegalArgumentException; +import java.lang.Object; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class CreateAgent { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateAgent", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateAgent", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateAgent", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass, TypeReference typeReference) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/agents", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + typeReference); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "body", + "json", + false); + if (serializedRequestBody == null) { + throw new IllegalArgumentException("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(CreateAgentRequest request) throws Exception { + HttpRequest req = buildRequest(request, CreateAgentRequest.class, new TypeReference() {}); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(CreateAgentRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public CreateAgentResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + CreateAgentResponse.Builder resBuilder = + CreateAgentResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + CreateAgentResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(CreateAgentRequest request) throws Exception { + HttpRequest req = buildRequest(request, CreateAgentRequest.class, new TypeReference() {}); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(CreateAgentRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.CreateAgentResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.CreateAgentResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.CreateAgentResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withAgent); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/CreateInteraction.java b/src/main/java/com/google/genai/gaos/operations/CreateInteraction.java new file mode 100644 index 00000000000..d42b62c1e2c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/CreateInteraction.java @@ -0,0 +1,357 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.CreateInteractionClientError; +import com.google.genai.gaos.models.errors.CreateInteractionServerError; +import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.interactions.Interaction; +import com.google.genai.gaos.models.operations.CreateInteractionRequest; +import com.google.genai.gaos.models.operations.CreateInteractionResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.SerializedBody; +import com.google.genai.gaos.utils.Utils.JsonShape; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.IllegalArgumentException; +import java.lang.Object; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class CreateInteraction { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateInteraction", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateInteraction", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateInteraction", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass, TypeReference typeReference) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/interactions", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + typeReference); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "body", + "json", + false); + if (serializedRequestBody == null) { + throw new IllegalArgumentException("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json;q=1, text/event-stream;q=0") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(CreateInteractionRequest request) throws Exception { + HttpRequest req = buildRequest(request, CreateInteractionRequest.class, new TypeReference() {}); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(CreateInteractionRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public CreateInteractionResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + CreateInteractionResponse.Builder resBuilder = + CreateInteractionResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + CreateInteractionResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return res.withInteraction(Utils.unmarshal(response, new TypeReference() {})); + } + if (Utils.contentTypeMatches(contentType, "text/event-stream")) { + Utils.setSseSentinel(res, "[DONE]"); + return res; + } else { + throw SDKException.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); + } + } + 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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(CreateInteractionRequest request) throws Exception { + HttpRequest req = buildRequest(request, CreateInteractionRequest.class, new TypeReference() {}); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(CreateInteractionRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.CreateInteractionResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.CreateInteractionResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.CreateInteractionResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withInteraction); + } else if (Utils.contentTypeMatches(contentType, "text/event-stream")) { + Utils.setSseSentinel(res, "[DONE]"); + return CompletableFuture.completedFuture(res); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return CreateInteractionClientError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return CreateInteractionServerError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/CreateWebhook.java b/src/main/java/com/google/genai/gaos/operations/CreateWebhook.java new file mode 100644 index 00000000000..80a7cc38369 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/CreateWebhook.java @@ -0,0 +1,334 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.operations.CreateWebhookRequest; +import com.google.genai.gaos.models.operations.CreateWebhookResponse; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.SerializedBody; +import com.google.genai.gaos.utils.Utils.JsonShape; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.IllegalArgumentException; +import java.lang.Object; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class CreateWebhook { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "CreateWebhook", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass, TypeReference typeReference) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/webhooks", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + typeReference); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "body", + "json", + false); + if (serializedRequestBody == null) { + throw new IllegalArgumentException("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(CreateWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, CreateWebhookRequest.class, new TypeReference() {}); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(CreateWebhookRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public CreateWebhookResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + CreateWebhookResponse.Builder resBuilder = + CreateWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + CreateWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(CreateWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, CreateWebhookRequest.class, new TypeReference() {}); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(CreateWebhookRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.CreateWebhookResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.CreateWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.CreateWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withWebhook); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/DeleteAgent.java b/src/main/java/com/google/genai/gaos/operations/DeleteAgent.java new file mode 100644 index 00000000000..e9f79d9d888 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/DeleteAgent.java @@ -0,0 +1,317 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.interactions.Empty; +import com.google.genai.gaos.models.operations.DeleteAgentRequest; +import com.google.genai.gaos.models.operations.DeleteAgentResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class DeleteAgent { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "DeleteAgent", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "DeleteAgent", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "DeleteAgent", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/agents/{id}", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "DELETE"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(DeleteAgentRequest request) throws Exception { + HttpRequest req = buildRequest(request, DeleteAgentRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(DeleteAgentRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public DeleteAgentResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + DeleteAgentResponse.Builder resBuilder = + DeleteAgentResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + DeleteAgentResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(DeleteAgentRequest request) throws Exception { + HttpRequest req = buildRequest(request, DeleteAgentRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(DeleteAgentRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.DeleteAgentResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.DeleteAgentResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.DeleteAgentResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withEmpty); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/DeleteInteraction.java b/src/main/java/com/google/genai/gaos/operations/DeleteInteraction.java new file mode 100644 index 00000000000..6c4c75bc369 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/DeleteInteraction.java @@ -0,0 +1,324 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +import com.google.genai.gaos.SDKConfiguration; +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.operations.DeleteInteractionRequest; +import com.google.genai.gaos.models.operations.DeleteInteractionResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class DeleteInteraction { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "deleteInteraction", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "deleteInteraction", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "deleteInteraction", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/interactions/{id}", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "DELETE"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(DeleteInteractionRequest request) throws Exception { + HttpRequest req = buildRequest(request, DeleteInteractionRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(DeleteInteractionRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public DeleteInteractionResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + DeleteInteractionResponse.Builder resBuilder = + DeleteInteractionResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + DeleteInteractionResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + // no content + return res; + } + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw DeleteInteractionClientError.from(response); + } else { + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(DeleteInteractionRequest request) throws Exception { + HttpRequest req = buildRequest(request, DeleteInteractionRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(DeleteInteractionRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.DeleteInteractionResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.DeleteInteractionResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.DeleteInteractionResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + // no content + return CompletableFuture.completedFuture(res); + } + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return DeleteInteractionClientError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return DeleteInteractionServerError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/DeleteWebhook.java b/src/main/java/com/google/genai/gaos/operations/DeleteWebhook.java new file mode 100644 index 00000000000..a98da6c5d88 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/DeleteWebhook.java @@ -0,0 +1,317 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.interactions.Empty; +import com.google.genai.gaos.models.operations.DeleteWebhookRequest; +import com.google.genai.gaos.models.operations.DeleteWebhookResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class DeleteWebhook { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "DeleteWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "DeleteWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "DeleteWebhook", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/webhooks/{id}", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "DELETE"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(DeleteWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, DeleteWebhookRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(DeleteWebhookRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public DeleteWebhookResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + DeleteWebhookResponse.Builder resBuilder = + DeleteWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + DeleteWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(DeleteWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, DeleteWebhookRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(DeleteWebhookRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.DeleteWebhookResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.DeleteWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.DeleteWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withEmpty); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/GetAgent.java b/src/main/java/com/google/genai/gaos/operations/GetAgent.java new file mode 100644 index 00000000000..63f76936de0 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/GetAgent.java @@ -0,0 +1,317 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.agents.Agent; +import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.operations.GetAgentRequest; +import com.google.genai.gaos.models.operations.GetAgentResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class GetAgent { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "GetAgent", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "GetAgent", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "GetAgent", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/agents/{id}", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(GetAgentRequest request) throws Exception { + HttpRequest req = buildRequest(request, GetAgentRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(GetAgentRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public GetAgentResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + GetAgentResponse.Builder resBuilder = + GetAgentResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + GetAgentResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(GetAgentRequest request) throws Exception { + HttpRequest req = buildRequest(request, GetAgentRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(GetAgentRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.GetAgentResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.GetAgentResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.GetAgentResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withAgent); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/GetInteractionById.java b/src/main/java/com/google/genai/gaos/operations/GetInteractionById.java new file mode 100644 index 00000000000..7b49d02967c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/GetInteractionById.java @@ -0,0 +1,345 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.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; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class GetInteractionById { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "getInteractionById", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "getInteractionById", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "getInteractionById", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/interactions/{id}", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json;q=1, text/event-stream;q=0") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + + req.addQueryParams(Utils.getQueryParams( + klass, + request, + this.operationGlobals)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(GetInteractionByIdRequest request) throws Exception { + HttpRequest req = buildRequest(request, GetInteractionByIdRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(GetInteractionByIdRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public GetInteractionByIdResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + GetInteractionByIdResponse.Builder resBuilder = + GetInteractionByIdResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + GetInteractionByIdResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return res.withInteraction(Utils.unmarshal(response, new TypeReference() {})); + } + if (Utils.contentTypeMatches(contentType, "text/event-stream")) { + Utils.setSseSentinel(res, "[DONE]"); + return res; + } else { + throw SDKException.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); + } + } + 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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(GetInteractionByIdRequest request) throws Exception { + HttpRequest req = buildRequest(request, GetInteractionByIdRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(GetInteractionByIdRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.GetInteractionByIdResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.GetInteractionByIdResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.GetInteractionByIdResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withInteraction); + } else if (Utils.contentTypeMatches(contentType, "text/event-stream")) { + Utils.setSseSentinel(res, "[DONE]"); + return CompletableFuture.completedFuture(res); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return GetInteractionByIdClientError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return GetInteractionByIdServerError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/GetWebhook.java b/src/main/java/com/google/genai/gaos/operations/GetWebhook.java new file mode 100644 index 00000000000..073472673ae --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/GetWebhook.java @@ -0,0 +1,317 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.operations.GetWebhookRequest; +import com.google.genai.gaos.models.operations.GetWebhookResponse; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class GetWebhook { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "GetWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "GetWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "GetWebhook", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/webhooks/{id}", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(GetWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, GetWebhookRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(GetWebhookRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public GetWebhookResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + GetWebhookResponse.Builder resBuilder = + GetWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + GetWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(GetWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, GetWebhookRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(GetWebhookRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.GetWebhookResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.GetWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.GetWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withWebhook); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/ListAgents.java b/src/main/java/com/google/genai/gaos/operations/ListAgents.java new file mode 100644 index 00000000000..12362fa04cc --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/ListAgents.java @@ -0,0 +1,322 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.agents.AgentListResponse; +import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.operations.ListAgentsRequest; +import com.google.genai.gaos.models.operations.ListAgentsResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class ListAgents { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAgents", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAgents", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListAgents", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/agents", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + + req.addQueryParams(Utils.getQueryParams( + klass, + request, + this.operationGlobals)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(ListAgentsRequest request) throws Exception { + HttpRequest req = buildRequest(request, ListAgentsRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(ListAgentsRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public ListAgentsResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ListAgentsResponse.Builder resBuilder = + ListAgentsResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + ListAgentsResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(ListAgentsRequest request) throws Exception { + HttpRequest req = buildRequest(request, ListAgentsRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(ListAgentsRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.ListAgentsResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.ListAgentsResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.ListAgentsResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withAgentListResponse); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/ListWebhooks.java b/src/main/java/com/google/genai/gaos/operations/ListWebhooks.java new file mode 100644 index 00000000000..c6c7e95ee8c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/ListWebhooks.java @@ -0,0 +1,322 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.operations.ListWebhooksRequest; +import com.google.genai.gaos.models.operations.ListWebhooksResponse; +import com.google.genai.gaos.models.webhooks.WebhookListResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class ListWebhooks { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListWebhooks", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListWebhooks", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "ListWebhooks", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/webhooks", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "GET"); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + + req.addQueryParams(Utils.getQueryParams( + klass, + request, + this.operationGlobals)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(ListWebhooksRequest request) throws Exception { + HttpRequest req = buildRequest(request, ListWebhooksRequest.class); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(ListWebhooksRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public ListWebhooksResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ListWebhooksResponse.Builder resBuilder = + ListWebhooksResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + ListWebhooksResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(ListWebhooksRequest request) throws Exception { + HttpRequest req = buildRequest(request, ListWebhooksRequest.class); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(ListWebhooksRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.ListWebhooksResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.ListWebhooksResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.ListWebhooksResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withWebhookListResponse); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/Operations.java b/src/main/java/com/google/genai/gaos/operations/Operations.java new file mode 100644 index 00000000000..e654a46b29b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/Operations.java @@ -0,0 +1,73 @@ +/* +* 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.operations; + +import com.google.genai.gaos.utils.Blob; + +import java.io.InputStream; +import java.net.http.HttpResponse; +import java.util.concurrent.CompletableFuture; + +// Internal API only + +@SuppressWarnings("all") +public class Operations { + /** + * Base interface for all operations + */ + public interface Operation { + ResT handleResponse(HttpResponse response); + } + + /** + * Interface for operations that require a request parameter + */ + public interface RequestOperation extends Operation { + HttpResponse doRequest(ReqT request); + } + + /** + * Interface for operations that don't require a request parameter + */ + public interface RequestlessOperation extends Operation { + HttpResponse doRequest(); + } + + /** + * Base interface for all async operations + */ + public interface AsyncOperation { + CompletableFuture handleResponse(HttpResponse response); + } + + /** + * Interface for async operations that require a request parameter + */ + public interface AsyncRequestOperation extends AsyncOperation { + CompletableFuture> doRequest(ReqT request); + } + + /** + * Interface for async operations that don't require a request parameter + */ + public interface AsyncRequestlessOperation extends AsyncOperation { + CompletableFuture> doRequest(); + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/operations/PingWebhook.java b/src/main/java/com/google/genai/gaos/operations/PingWebhook.java new file mode 100644 index 00000000000..0b56b76e55d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/PingWebhook.java @@ -0,0 +1,330 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.operations.PingWebhookRequest; +import com.google.genai.gaos.models.operations.PingWebhookResponse; +import com.google.genai.gaos.models.webhooks.WebhookPingResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.SerializedBody; +import com.google.genai.gaos.utils.Utils.JsonShape; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.Object; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class PingWebhook { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "PingWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "PingWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "PingWebhook", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass, TypeReference typeReference) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/webhooks/{id}:ping", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + typeReference); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "body", + "json", + false); + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(PingWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, PingWebhookRequest.class, new TypeReference() {}); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(PingWebhookRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public PingWebhookResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + PingWebhookResponse.Builder resBuilder = + PingWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + PingWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(PingWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, PingWebhookRequest.class, new TypeReference() {}); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(PingWebhookRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.PingWebhookResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.PingWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.PingWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withWebhookPingResponse); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/RotateSigningSecret.java b/src/main/java/com/google/genai/gaos/operations/RotateSigningSecret.java new file mode 100644 index 00000000000..d463af8e445 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/RotateSigningSecret.java @@ -0,0 +1,330 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.operations.RotateSigningSecretRequest; +import com.google.genai.gaos.models.operations.RotateSigningSecretResponse; +import com.google.genai.gaos.models.webhooks.WebhookRotateSigningSecretResponse; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.SerializedBody; +import com.google.genai.gaos.utils.Utils.JsonShape; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.Object; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class RotateSigningSecret { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "RotateSigningSecret", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "RotateSigningSecret", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "RotateSigningSecret", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass, TypeReference typeReference) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/webhooks/{id}:rotateSigningSecret", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + typeReference); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "body", + "json", + false); + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(RotateSigningSecretRequest request) throws Exception { + HttpRequest req = buildRequest(request, RotateSigningSecretRequest.class, new TypeReference() {}); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(RotateSigningSecretRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public RotateSigningSecretResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + RotateSigningSecretResponse.Builder resBuilder = + RotateSigningSecretResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + RotateSigningSecretResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(RotateSigningSecretRequest request) throws Exception { + HttpRequest req = buildRequest(request, RotateSigningSecretRequest.class, new TypeReference() {}); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(RotateSigningSecretRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.RotateSigningSecretResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.RotateSigningSecretResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.RotateSigningSecretResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withWebhookRotateSigningSecretResponse); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/operations/UpdateWebhook.java b/src/main/java/com/google/genai/gaos/operations/UpdateWebhook.java new file mode 100644 index 00000000000..21a6879e3d8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/operations/UpdateWebhook.java @@ -0,0 +1,335 @@ +/* +* 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.operations; + +import static com.google.genai.gaos.operations.Operations.RequestOperation; +import static com.google.genai.gaos.utils.Exceptions.unchecked; +import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation; + +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.operations.UpdateWebhookRequest; +import com.google.genai.gaos.models.operations.UpdateWebhookResponse; +import com.google.genai.gaos.models.webhooks.Webhook; +import com.google.genai.gaos.utils.AsyncRetries; +import com.google.genai.gaos.utils.BackoffStrategy; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.Globals; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.HTTPRequest; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.Hook.AfterErrorContextImpl; +import com.google.genai.gaos.utils.Hook.AfterSuccessContextImpl; +import com.google.genai.gaos.utils.Hook.BeforeRequestContextImpl; +import com.google.genai.gaos.utils.NonRetryableException; +import com.google.genai.gaos.utils.Options; +import com.google.genai.gaos.utils.Retries; +import com.google.genai.gaos.utils.RetryConfig; +import com.google.genai.gaos.utils.SerializedBody; +import com.google.genai.gaos.utils.Utils.JsonShape; +import com.google.genai.gaos.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.Object; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + + +@SuppressWarnings("all") +public class UpdateWebhook { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final List retryStatusCodes; + final RetryConfig retryConfig; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = this.sdkConfiguration.serverUrl(); + this.securitySource = this.sdkConfiguration.securitySource(); + options + .ifPresent(o -> o.validate(List.of(Options.Option.RETRY_CONFIG))); + this.retryStatusCodes = List.of("408", "409", "429", "5XX"); + this.retryConfig = options + .flatMap(Options::retryConfig) + .or(sdkConfiguration::retryConfig) + .orElse(RetryConfig.builder().attemptCountBackoff(4, BackoffStrategy.builder() + .initialInterval(500, TimeUnit.MILLISECONDS) + .maxInterval(8000, TimeUnit.MILLISECONDS) + .baseFactor((double) (2)) + .maxElapsedTime(30000, TimeUnit.MILLISECONDS) + .retryConnectError(true) + .build()) + .build()); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("pathParam", "api_version") + .ifPresent(param -> operationGlobals.putParam("pathParam", "api_version", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "UpdateWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "UpdateWebhook", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "UpdateWebhook", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass, TypeReference typeReference) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/{api_version}/webhooks/{id}", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "PATCH"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + typeReference); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "body", + "json", + false); + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + + req.addQueryParams(Utils.getQueryParams( + klass, + request, + this.operationGlobals)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync( + SDKConfiguration sdkConfiguration, Optional options, + Headers _headers) { + super( + sdkConfiguration, options, + _headers); + } + + private HttpRequest onBuildRequest(UpdateWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, UpdateWebhookRequest.class, new TypeReference() {}); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(UpdateWebhookRequest request) { + Retries retries = Retries.builder() + .action((attempt) -> { + HttpRequest r; + try { + r = onBuildRequest(request); + } catch (Exception e) { + throw new NonRetryableException(e); + } + try { + HttpResponse httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + return onError(httpRes, null); + } + return httpRes; + } catch (Exception e) { + return onError(null, e); + } + }) + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .build(); + return unchecked(() -> onSuccess(retries.run())).get(); + } + + + @Override + public UpdateWebhookResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + UpdateWebhookResponse.Builder resBuilder = + UpdateWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + UpdateWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw SDKException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw SDKException.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 SDKException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + private final ScheduledExecutorService retryScheduler; + + public Async( + SDKConfiguration sdkConfiguration, Optional options, + ScheduledExecutorService retryScheduler, Headers _headers) { + super( + sdkConfiguration, options, + _headers); + this.retryScheduler = retryScheduler; + } + + private CompletableFuture onBuildRequest(UpdateWebhookRequest request) throws Exception { + HttpRequest req = buildRequest(request, UpdateWebhookRequest.class, new TypeReference() {}); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(UpdateWebhookRequest request) { + AsyncRetries retries = AsyncRetries.builder() + .retryConfig(retryConfig) + .statusCodes(retryStatusCodes) + .scheduler(retryScheduler) + .build(); + return retries.retry((attempt) -> unchecked(() -> onBuildRequest(request)).get() + .thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity())) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.google.genai.gaos.models.operations.async.UpdateWebhookResponse.Builder resBuilder = + com.google.genai.gaos.models.operations.async.UpdateWebhookResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.google.genai.gaos.models.operations.async.UpdateWebhookResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "default")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withWebhook); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/AsyncHook.java b/src/main/java/com/google/genai/gaos/utils/AsyncHook.java new file mode 100644 index 00000000000..8c502e92cdb --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/AsyncHook.java @@ -0,0 +1,117 @@ +/* +* 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.utils; + + +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.concurrent.CompletableFuture; +import java.util.Optional; +import java.util.UUID; + +/** + * Utility class for defining async hook interfaces. + */ +@SuppressWarnings("all") +public final class AsyncHook { + + private AsyncHook() { + // prevent instantiation + } + + /** + * Specifies how a request is transformed before sending. + */ + @FunctionalInterface + public interface BeforeRequest { + + /** + * Transforms the given {@link HttpRequest} before sending. + * + *

Note that {@link HttpRequest} is immutable. To modify the request you can use + * {@code HttpRequest#newBuilder(HttpRequest, BiPredicate)} with + * JDK 16 and later (which will copy the request for modification in a builder). + * If that method is not available then use {@link Helpers#copy} (which also returns + * a builder). + * + * @param context context for the hook call + * @param request request to be transformed + * @return transformed request + */ + CompletableFuture beforeRequest(Hook.BeforeRequestContext context, HttpRequest request); + + BeforeRequest DEFAULT = (context, request) -> CompletableFuture.completedFuture(request); + } + + /** + * Specifies how a response is transformed before response processing. + */ + @FunctionalInterface + public interface AfterSuccess { + + /** + * Transforms the given response before response processing occurs. + * + * @param context context for the hook call + * @param response response to be transformed + * @return transformed response + */ + CompletableFuture> afterSuccess(Hook.AfterSuccessContext context, HttpResponse response); + + AfterSuccess DEFAULT = (context, response) -> CompletableFuture.completedFuture(response); + } + + /** + * Specifies what happens if a request action throws an Exception. + */ + @FunctionalInterface + public interface AfterError { + + /** + * Either returns an HttpResponse or throws an Exception. Must be passed either + * a response or an error (both can't be absent). + * + * @param context context for the error + * @param response response information if available. + * @param error the optional exception. If response present then the error is for-info + * only, it was the last error in the chain of AfterError hook + * calls leading to this one + * @return HTTP response if method decides that an exception is not to be thrown + */ + CompletableFuture> afterError( + Hook.AfterErrorContext context, + HttpResponse response, + Throwable error); + + AfterError DEFAULT = (context, response, error) -> Optional.ofNullable(response) + .map(CompletableFuture::completedFuture) + .orElse(CompletableFuture.failedFuture(error)); + } + + public static final class IdempotencyHook implements BeforeRequest { + + @Override + public CompletableFuture beforeRequest(Hook.BeforeRequestContext context, HttpRequest request) { + HttpRequest.Builder b = Helpers.copy(request); + b.header("Idempotency-Key", UUID.randomUUID().toString()); + return CompletableFuture.completedFuture(b.build()); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/AsyncHooks.java b/src/main/java/com/google/genai/gaos/utils/AsyncHooks.java new file mode 100644 index 00000000000..09a55fc82c2 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/AsyncHooks.java @@ -0,0 +1,201 @@ +/* +* 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.utils; + +import java.net.http.HttpResponse; +import java.net.http.HttpRequest; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicBoolean; + +import com.google.genai.gaos.utils.AsyncHook.AfterError; +import com.google.genai.gaos.utils.AsyncHook.AfterSuccess; +import com.google.genai.gaos.utils.AsyncHook.BeforeRequest; +import com.google.genai.gaos.utils.Hook.AfterErrorContext; +import com.google.genai.gaos.utils.Hook.AfterSuccessContext; +import com.google.genai.gaos.utils.Hook.BeforeRequestContext; +import com.google.genai.gaos.utils.Hooks.FailEarlyException; +import com.google.genai.gaos.utils.Blob; + +/** + * Async hook registry for runtime request/response processing. + * + *

Example usage: + *

+ * asyncHooks.registerBeforeRequest((context, request) ->
+ *     CompletableFuture.completedFuture(
+ *         Helpers.copy(request)
+ *             .header("transaction-id", UUID.randomUUID().toString())
+ *             .build()));
+ * 
+ */ +// ThreadSafe +@SuppressWarnings("all") +public class AsyncHooks implements BeforeRequest, AfterSuccess, AfterError { + + private static final SpeakeasyLogger logger = SpeakeasyLogger.getLogger(AsyncHooks.class); + + // we use CopyOnWriteArrayList for thread safety + private final List beforeRequestHooks = new CopyOnWriteArrayList<>(); + private final List afterSuccessHooks = new CopyOnWriteArrayList<>(); + private final List afterErrorHooks = new CopyOnWriteArrayList<>(); + + public AsyncHooks() { + } + + /** + * Registers an async before-request hook. Hooks are chained in registration order. + * + * @param beforeRequest async hook returning {@code CompletableFuture} + * @return this + */ + public AsyncHooks registerBeforeRequest(BeforeRequest beforeRequest) { + Utils.checkNotNull(beforeRequest, "beforeRequest"); + this.beforeRequestHooks.add(beforeRequest); + logger.debug("Registered async BeforeRequest hook: {} (total: {})", beforeRequest.getClass().getSimpleName(), beforeRequestHooks.size()); + return this; + } + + /** + * Registers an async after-success hook. Hooks are chained in registration order. + * + * @param afterSuccess async hook returning {@code CompletableFuture} + * @return this + */ + public AsyncHooks registerAfterSuccess(AfterSuccess afterSuccess) { + Utils.checkNotNull(afterSuccess, "afterSuccess"); + this.afterSuccessHooks.add(afterSuccess); + logger.debug("Registered async AfterSuccess hook: {} (total: {})", afterSuccess.getClass().getSimpleName(), afterSuccessHooks.size()); + return this; + } + + /** + * Registers an async after-error hook. Hooks are chained in registration order. + * + * @param afterError async hook for error handling + * @return this + */ + public AsyncHooks registerAfterError(AfterError afterError) { + Utils.checkNotNull(afterError, "afterError"); + this.afterErrorHooks.add(afterError); + logger.debug("Registered async AfterError hook: {} (total: {})", afterError.getClass().getSimpleName(), afterErrorHooks.size()); + return this; + } + + @Override + public CompletableFuture beforeRequest(BeforeRequestContext context, HttpRequest request) { + Utils.checkNotNull(context, "context"); + Utils.checkNotNull(request, "request"); + + if (logger.isTraceEnabled() && !beforeRequestHooks.isEmpty()) { + logger.trace("Executing {} async beforeRequest hook(s) for operation: {}", beforeRequestHooks.size(), context.operationId()); + } + + CompletableFuture result = CompletableFuture.completedFuture(request); + + for (BeforeRequest hook : beforeRequestHooks) { + result = result.thenCompose(req -> hook.beforeRequest(context, req)); + } + + return result; + } + + @Override + public CompletableFuture> afterSuccess( + AfterSuccessContext context, + HttpResponse response) { + Utils.checkNotNull(context, "context"); + Utils.checkNotNull(response, "response"); + + if (logger.isTraceEnabled() && !afterSuccessHooks.isEmpty()) { + logger.trace("Executing {} async afterSuccess hook(s) for operation: {}", afterSuccessHooks.size(), context.operationId()); + } + + CompletableFuture> result = CompletableFuture.completedFuture(response); + + for (AfterSuccess hook : afterSuccessHooks) { + result = result.handle((resp, ex) -> + hook.afterSuccess(context, resp) + .thenApply(hookResp -> { + if (hookResp == null) { + throw new IllegalStateException( + "afterSuccess must return a non-null response"); + } + return hookResp; + }) + ).thenCompose(future -> future); + } + + return result; + } + + @Override + public CompletableFuture> afterError( + AfterErrorContext context, + HttpResponse response, + Throwable error) { + Utils.checkNotNull(context, "context"); + Utils.checkArgument( + (response != null) ^ (error != null), + "one and only one of response or error must be present"); + + if (logger.isTraceEnabled() && !afterErrorHooks.isEmpty()) { + logger.trace("Executing {} async afterError hook(s) for operation: {}", afterErrorHooks.size(), context.operationId()); + } + + CompletableFuture> result; + if (response != null) { + result = CompletableFuture.completedFuture(response); + } else { + result = CompletableFuture.failedFuture(error); + } + + AtomicBoolean failedEarly = new AtomicBoolean(false); + for (AfterError hook : afterErrorHooks) { + result = result.handle((resp, ex) -> { + if (failedEarly.get()) { + throw (FailEarlyException) ex; + } + return hook.afterError(context, resp, ex) + .handle((hookResp, hookErr) -> { + if (hookErr != null) { + if (hookErr instanceof FailEarlyException) { + failedEarly.set(true); + throw (FailEarlyException) hookErr; + } + logger.debug("Async hook threw exception: {}", hookErr.getClass().getSimpleName()); + throw Exceptions.unchecked(hookErr); + } + if (hookResp == null) { + throw new IllegalStateException( + "afterError must either throw an exception or return a non-null response"); + } + + return hookResp; + }); + } + ).thenCompose(future -> future); + } + + return result; + } + +} diff --git a/src/main/java/com/google/genai/gaos/utils/AsyncResponse.java b/src/main/java/com/google/genai/gaos/utils/AsyncResponse.java new file mode 100644 index 00000000000..47af260d01c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/AsyncResponse.java @@ -0,0 +1,41 @@ +/* +* 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.utils; +import com.google.genai.gaos.utils.Blob; +import java.net.http.HttpResponse; + +@SuppressWarnings("all") +public interface AsyncResponse { + + /** + * Returns the value of the Content-Type header. + **/ + String contentType(); + + /** + * Returns the HTTP status code. + **/ + int statusCode(); + + /** + * Returns the raw response. + **/ + HttpResponse rawResponse(); +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/AsyncRetries.java b/src/main/java/com/google/genai/gaos/utils/AsyncRetries.java new file mode 100644 index 00000000000..2e9929b982f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/AsyncRetries.java @@ -0,0 +1,345 @@ +/* +* 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.utils; + +import java.io.IOException; +import java.net.ConnectException; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.time.Instant; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.concurrent.*; +import java.util.function.Supplier; +import com.google.genai.gaos.utils.Blob; + +@SuppressWarnings("all") +public class AsyncRetries { + + private static final SpeakeasyLogger logger = SpeakeasyLogger.getLogger(AsyncRetries.class); + + private final RetryConfig retryConfig; + private final List retriableStatusCodes; + private final ScheduledExecutorService scheduler; + + @FunctionalInterface + public interface RetryTask { + CompletableFuture> get(int attempt); + } + + private AsyncRetries(RetryConfig retryConfig, + List retriableStatusCodes, + ScheduledExecutorService scheduler) { + Utils.checkNotNull(retryConfig, "retryConfig"); + Utils.checkNotNull(retriableStatusCodes, "statusCodes"); + if (retriableStatusCodes.isEmpty()) { + throw new IllegalArgumentException("statusCodes list cannot be empty"); + } + this.retryConfig = retryConfig; + this.retriableStatusCodes = retriableStatusCodes; + this.scheduler = scheduler; + } + + public CompletableFuture> retry( + RetryTask task + ) { + switch (retryConfig.strategy()) { + case BACKOFF: + CompletableFuture> future = new CompletableFuture<>(); + BackoffStrategy backoff = retryConfig.backoff() + // We want to fail fast during misconfigurations. + .orElseThrow(() -> new IllegalArgumentException("Backoff strategy is not defined")); + attempt(task, future, backoff, new State(0, Instant.now())); + return future; + case ATTEMPT_COUNT_BACKOFF: + future = new CompletableFuture<>(); + backoff = retryConfig.backoff() + // We want to fail fast during misconfigurations. + .orElseThrow(() -> new IllegalArgumentException("Backoff strategy is not defined")); + attempt(task, future, backoff, new State(0, Instant.now())); + return future; + case NONE: + return task.get(0); + default: + throw new IllegalArgumentException("Unsupported retry strategy: " + retryConfig.strategy()); + } + } + + public CompletableFuture> retry( + Supplier>> task + ) { + return retry((attempt) -> task.get()); + } + + private void attempt(RetryTask task, + CompletableFuture> result, + BackoffStrategy backoff, + State state) { + if (state.count() > 0) { + logger.debug("Async retry attempt {} after backoff", state.count()); + } + CompletableFuture> attemptFuture; + try { + attemptFuture = task.get((int) state.count()); + } catch (Exception throwable) { + handleThrowable(task, result, backoff, state, throwable); + return; + } + attemptFuture.whenComplete((response, throwable) -> { + if (throwable == null) { + RetryDecision decision = shouldRetry(response); + if (decision.retry()) { + maybeRetry(task, result, backoff, state, new AsyncRetryableException(response)); + return; + } + result.complete(response); + return; + } + handleThrowable(task, result, backoff, state, throwable); + }); + } + + private void handleThrowable(RetryTask task, + CompletableFuture> result, + BackoffStrategy backoff, + State state, + Throwable throwable) { + Throwable e = (throwable instanceof CompletionException && throwable.getCause() != null) + ? throwable.getCause() + : throwable; + if (e instanceof AsyncRetryableException) { + maybeRetry(task, result, backoff, state, e); + return; + } + if (e instanceof IOException) { + if (shouldRetryIOException(e, backoff)) { + maybeRetry(task, result, backoff, state, e); + return; + } + } + logger.debug("Non-retryable exception encountered: {}", e.getClass().getSimpleName()); + result.completeExceptionally(new NonRetryableException(e)); + } + + private boolean shouldRetryIOException(Throwable e, BackoffStrategy backoff) { + if (e instanceof ConnectException && backoff.retryConnectError()) return true; + String message = e.getMessage(); + if (message == null) return false; + return (message.contains("Connect timed out") && backoff.retryConnectError()) + || (message.contains("Read timed out") && backoff.retryReadTimeoutError()); + } + + private RetryDecision shouldRetry(HttpResponse response) { + boolean matched = retriableStatusCodes.stream() + .anyMatch(pattern -> Utils.statusCodeMatches(response.statusCode(), pattern)); + return new RetryDecision(matched); + } + + private long retryAfterMs(HttpResponse response) { + String retryAfterMs = response.headers().firstValue("retry-after-ms").orElse(null); + if (retryAfterMs != null && !retryAfterMs.isEmpty()) { + try { + long milliseconds = Long.parseLong(retryAfterMs); + return milliseconds < 0 ? 0 : milliseconds; + } catch (NumberFormatException ignored) { + } + } + + String retryAfter = response.headers().firstValue("retry-after").orElse(null); + if (retryAfter == null || retryAfter.isEmpty()) { + return 0; + } + try { + long seconds = Long.parseLong(retryAfter); + return seconds < 0 ? 0 : seconds * 1000; + } catch (NumberFormatException ignored) { + } + try { + ZonedDateTime retryDate = ZonedDateTime.parse(retryAfter, DateTimeFormatter.RFC_1123_DATE_TIME); + long deltaMs = retryDate.toInstant().toEpochMilli() - System.currentTimeMillis(); + return deltaMs > 0 ? deltaMs : 0; + } catch (Exception ignored) { + } + return 0; + } + + private void maybeRetry(RetryTask task, + CompletableFuture> result, + BackoffStrategy backoff, + State state, + Throwable e) { + Duration timeSinceStart = Duration.between(state.startedAt(), Instant.now()); + if (retryConfig.strategy() == RetryConfig.Strategy.ATTEMPT_COUNT_BACKOFF + && state.count() >= retryConfig.maxRetries().orElse(0)) { + logger.debug("Async retry exhausted after {} attempts", state.count() + 1); + if (e instanceof AsyncRetryableException) { + result.complete(((AsyncRetryableException) e).response()); + return; + } + result.completeExceptionally(e); + return; + } + if (retryConfig.strategy() == RetryConfig.Strategy.BACKOFF + && timeSinceStart.toMillis() > backoff.maxElapsedTimeMs()) { + // retry exhausted + logger.debug("Async retry exhausted after {}ms, {} attempts", timeSinceStart.toMillis(), state.count() + 1); + if (e instanceof AsyncRetryableException) { + result.complete(((AsyncRetryableException) e).response()); + return; + } + result.completeExceptionally(e); + return; + } + + long intervalMs; + if (e instanceof AsyncRetryableException) { + intervalMs = retryAfterMs(((AsyncRetryableException) e).response()); + } else { + intervalMs = 0; + } + + if (intervalMs <= 0) { + double computed = backoff.initialIntervalMs() * Math.pow(backoff.baseFactor(), state.count()); + double jitterMs = backoff.jitterFactor() * computed; + if (retryConfig.strategy() == RetryConfig.Strategy.ATTEMPT_COUNT_BACKOFF) { + computed = computed - Math.random() * jitterMs; + } else { + computed = computed - jitterMs + Math.random() * (2 * jitterMs + 1); + } + computed = Math.min(computed, backoff.maxIntervalMs()); + intervalMs = (long) computed; + } + + if (logger.isTraceEnabled()) { + String reason = e instanceof AsyncRetryableException + ? "status " + ((AsyncRetryableException) e).response().statusCode() + : e.getClass().getSimpleName(); + logger.trace("Async retrying due to {} - waiting {}ms before attempt {}", reason, intervalMs, state.count() + 1); + } + + try { + scheduler.schedule( + () -> attempt(task, result, backoff, state.countAttempt()), + intervalMs, + TimeUnit.MILLISECONDS); + } catch (RejectedExecutionException exception) { + result.completeExceptionally(exception); + } + } + + public void shutdown() { + scheduler.shutdown(); + } + + public static Builder builder() { + return new Builder(); + } + + public final static class Builder { + + private RetryConfig retryConfig; + private List statusCodes; + private ScheduledExecutorService scheduler; + + private Builder() { + } + + /** + * Defines the retry configuration. + * + * @param retryConfig The retry configuration to use. + * @return The builder instance. + */ + public Builder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + /** + * Defines the status codes that should be considered as errors. + * + * @param statusCodes The list of status codes to treat as errors. + * @return The builder instance. + */ + public Builder statusCodes(List statusCodes) { + Utils.checkNotNull(statusCodes, "statusCodes"); + if (statusCodes.isEmpty()) { + throw new IllegalArgumentException("statusCodes list cannot be empty"); + } + this.statusCodes = statusCodes; + return this; + } + + /** + * Defines the scheduler that will be used to schedule and execute retry attempts. + * Recommend using a globally shared executor for this. + * + * @param scheduler An instance of {@link ScheduledExecutorService} + * @return The builder instance. + */ + public Builder scheduler(ScheduledExecutorService scheduler) { + Utils.checkNotNull(scheduler, "scheduler"); + this.scheduler = scheduler; + return this; + } + + public AsyncRetries build() { + return new AsyncRetries(retryConfig, statusCodes, scheduler); + } + } + + private static class State { + private long attempt; + private final Instant startedAt; + + public State(long attempt, Instant startedAt) { + this.attempt = attempt; + this.startedAt = startedAt; + } + + public long count() { + return attempt; + } + + public Instant startedAt() { + return startedAt; + } + + public State countAttempt() { + attempt++; + return this; + } + } + + private static class RetryDecision { + private final boolean retry; + + public RetryDecision(boolean retry) { + this.retry = retry; + } + + public boolean retry() { + return retry; + } + } + +} diff --git a/src/main/java/com/google/genai/gaos/utils/AsyncRetryableException.java b/src/main/java/com/google/genai/gaos/utils/AsyncRetryableException.java new file mode 100644 index 00000000000..81e14054508 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/AsyncRetryableException.java @@ -0,0 +1,37 @@ +/* +* 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.utils; + +import com.google.genai.gaos.utils.Blob; + +import java.net.http.HttpResponse; + +@SuppressWarnings("all") +public final class AsyncRetryableException extends Exception { + private final HttpResponse response; + + public AsyncRetryableException(HttpResponse response) { + this.response = response; + } + + public HttpResponse response() { + return response; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/BackoffStrategy.java b/src/main/java/com/google/genai/gaos/utils/BackoffStrategy.java new file mode 100644 index 00000000000..d5480eaa4b5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/BackoffStrategy.java @@ -0,0 +1,266 @@ +/* +* 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.utils; + +import java.util.concurrent.TimeUnit; + +/** + * Exponential Backoff Strategy with Jitter + * + * The duration between consecutive attempts is calculated as follows: + * intervalMs = min(maxIntervalMs, initialIntervalMs*(baseFactor^attempts) +/- r) + * where baseFactor is the base factor and r a random value between 0 and jitterFactor*intervalMs. + */ +@SuppressWarnings("all") +public class BackoffStrategy { + + private static final long DEFAULT_INITIAL_INTERVAL_MS = 500L; + private static final long DEFAULT_MAX_INTERVAL_MS = 60000L; + private static final long DEFAULT_MAX_ELAPSED_TIME_MS = 3600000L; + private static final double DEFAULT_EXPONENT = 1.5; + private static final double DEFAULT_JITTER_FACTOR = 0.5; + private static final boolean DEFAULT_RETRY_CONNECT_ERROR = false; + private static final boolean DEFAULT_RETRY_READ_TIMEOUT_ERROR = false; + + private final long initialIntervalMs; + private final long maxIntervalMs; + private final long maxElapsedTimeMs; + private final double baseFactor; + private final double jitterFactor; + private final boolean retryConnectError; + private final boolean retryReadTimeoutError; + + private BackoffStrategy(long initialIntervalMs, + long maxIntervalMs, + long maxElapsedTimeMs, + double baseFactor, + double jitterFactor, + boolean retryConnectError, + boolean retryReadTimeoutError) { + this.initialIntervalMs = initialIntervalMs; + this.maxIntervalMs = maxIntervalMs; + this.maxElapsedTimeMs = maxElapsedTimeMs; + this.baseFactor = baseFactor; + this.jitterFactor = jitterFactor; + this.retryConnectError = retryConnectError; + this.retryReadTimeoutError = retryReadTimeoutError; + } + + public static BackoffStrategy withDefaults() { + return BackoffStrategy.builder().build(); + } + + public long initialIntervalMs() { + return initialIntervalMs; + } + + public long maxIntervalMs() { + return maxIntervalMs; + } + + public double baseFactor() { + return baseFactor; + } + + /** + * @deprecated use {@link #baseFactor()} instead. + */ + @Deprecated + public double exponent() { + return baseFactor; + } + + public long maxElapsedTimeMs() { + return maxElapsedTimeMs; + } + + public double jitterFactor() { + return jitterFactor; + } + + public boolean retryConnectError() { + return retryConnectError; + } + + public boolean retryReadTimeoutError() { + return retryReadTimeoutError; + } + + public final static Builder builder() { + return new Builder(); + } + + public final static class Builder { + + private long initialIntervalMs = DEFAULT_INITIAL_INTERVAL_MS; + private long maxIntervalMs = DEFAULT_MAX_INTERVAL_MS; + private long maxElapsedTimeMs = DEFAULT_MAX_ELAPSED_TIME_MS; + private double baseFactor = DEFAULT_EXPONENT; + private double jitterFactor = DEFAULT_JITTER_FACTOR; + private boolean retryConnectError = DEFAULT_RETRY_CONNECT_ERROR; + private boolean retryReadTimeoutError = DEFAULT_RETRY_READ_TIMEOUT_ERROR; + + private Builder() {} + + /** + * Sets the initial interval + * + * @param duration The initial interval. + * @param unit The time unit associated with duration. + * @return The builder instance. + */ + public Builder initialInterval(long duration, TimeUnit unit) { + Utils.checkNotNull(unit, "unit"); + if (duration < 0) { + throw new IllegalArgumentException("initialInterval must be positive"); + } + this.initialIntervalMs = unit.toMillis(duration); + return this; + } + + /** + * Sets the maximum interval + * + * @param duration The maximum interval. + * @param unit The time unit associated with duration. + * @return The builder instance. + */ + public Builder maxInterval(long duration, TimeUnit unit) { + Utils.checkNotNull(unit, "unit"); + if (duration <= 0) { + throw new IllegalArgumentException("maxInterval must be strictly positive"); + } + this.maxIntervalMs = unit.toMillis(duration); + return this; + } + + /** + * Sets the maximum elapsed time + * + * @param duration The maximum elapsed time. + * @param unit The time unit associated with duration. + * @return The builder instance. + */ + public Builder maxElapsedTime(long duration, TimeUnit unit) { + Utils.checkNotNull(unit, "unit"); + if (duration < 0) { + throw new IllegalArgumentException("maxElapsedTime must be positive"); + } + this.maxElapsedTimeMs = unit.toMillis(duration); + return this; + } + + /** + * Sets the backoff base factor. + * + * @param baseFactor The base factor to use. + * @return The builder instance. + */ + public Builder baseFactor(double baseFactor) { + if (baseFactor <= 0 ) { + throw new IllegalArgumentException("baseFactor must be strictly positive"); + } + this.baseFactor = baseFactor; + return this; + } + + /** + * Sets the backoff base factor. + * + * @deprecated use {@link #baseFactor(double)} instead. + * @param baseFactor The base factor to use. + * @return The builder instance. + */ + @Deprecated + public Builder exponent(double baseFactor) { + if (baseFactor <= 0 ) { + throw new IllegalArgumentException("baseFactor must be strictly positive"); + } + this.baseFactor = baseFactor; + return this; + } + + /** + * Sets the jitter factor used to randomize the backoff interval. + * + * @param jitterFactor The jitter factor to use (default is 0.5f). + * @return The builder instance. + */ + public Builder jitterFactor(double jitterFactor) { + if (jitterFactor < 0 || jitterFactor > 1) { + throw new IllegalArgumentException("jitterFactor must be between 0 and 1"); + } + this.jitterFactor = jitterFactor; + return this; + } + + /** + * Specifies whether connection errors should be retried. + * + * @param retry Whether to retry on connection error. + * @return The builder instance. + */ + public Builder retryConnectError(boolean retry) { + this.retryConnectError = retry; + return this; + } + + /** + * Do not retry on connection error. + * + * @return The builder instance. + */ + public Builder throwConnectError() { + this.retryConnectError = false; + return this; + } + + /** + * Specifies whether Read Timeout errors should be retried. + * + * @param retry Whether to retry on Read Timeout error. + * @return The builder instance. + */ + public Builder retryReadTimeoutError(boolean retry) { + this.retryReadTimeoutError = retry; + return this; + } + + /** + * Do not retry on Read Timeout error. + * + * @return The builder instance. + */ + public Builder throwReadTimeoutError() { + this.retryReadTimeoutError = false; + return this; + } + + public BackoffStrategy build() { + return new BackoffStrategy(initialIntervalMs, + maxIntervalMs, + maxElapsedTimeMs, + baseFactor, + jitterFactor, + retryConnectError, + retryReadTimeoutError); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/BigDecimalString.java b/src/main/java/com/google/genai/gaos/utils/BigDecimalString.java new file mode 100644 index 00000000000..44be7ebed96 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/BigDecimalString.java @@ -0,0 +1,111 @@ +/* +* 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.utils; + +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Objects; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +// Internal API only + +// Note that Jackson 2.16.1 does not support @JsonValue and @JsonFormat combined so we must use +// a custom serializer/deserializer + +@JsonSerialize(using = BigDecimalString.Serializer.class) +@JsonDeserialize(using = BigDecimalString.Deserializer.class) +@SuppressWarnings("all") +public class BigDecimalString { + + private final BigDecimal value; + + public BigDecimalString(BigDecimal value) { + this.value = value; + } + + public BigDecimalString(String value) { + this(new BigDecimal(value)); + } + + public BigDecimal value() { + return value; + } + + @Override + public String toString() { + return value.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BigDecimalString other = (BigDecimalString) obj; + return Objects.equals(value, other.value); + } + + @SuppressWarnings("serial") + public static final class Serializer extends StdSerializer { + + protected Serializer() { + super(BigDecimalString.class); + } + + @Override + public void serialize(BigDecimalString value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeString(value.value.toString()); + } + } + + @SuppressWarnings("serial") + public static final class Deserializer extends StdDeserializer { + + protected Deserializer() { + super(BigDecimalString.class); + } + + @Override + public BigDecimalString deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String s = p.readValueAs(String.class); + return new BigDecimalString(new BigDecimal(s)); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/BigIntegerString.java b/src/main/java/com/google/genai/gaos/utils/BigIntegerString.java new file mode 100644 index 00000000000..48fee8b83b8 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/BigIntegerString.java @@ -0,0 +1,111 @@ +/* +* 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.utils; + +import java.io.IOException; +import java.math.BigInteger; +import java.util.Objects; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +// Internal API only + +// Note that Jackson 2.16.1 does not support @JsonValue and @JsonFormat combined so we must use +// a custom serializer/deserializer + +@JsonSerialize(using = BigIntegerString.Serializer.class) +@JsonDeserialize(using = BigIntegerString.Deserializer.class) +@SuppressWarnings("all") +public class BigIntegerString { + + private final BigInteger value; + + public BigIntegerString(BigInteger value) { + this.value = value; + } + + public BigIntegerString(String value) { + this(new BigInteger(value)); + } + + public BigInteger value() { + return value; + } + + @Override + public String toString() { + return value.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BigIntegerString other = (BigIntegerString) obj; + return Objects.equals(value, other.value); + } + + @SuppressWarnings("serial") + public static final class Serializer extends StdSerializer { + + protected Serializer() { + super(BigIntegerString.class); + } + + @Override + public void serialize(BigIntegerString value, JsonGenerator g, SerializerProvider provider) + throws IOException, JsonProcessingException { + g.writeString(value.value.toString()); + } + } + + @SuppressWarnings("serial") + public static final class Deserializer extends StdDeserializer { + + protected Deserializer() { + super(BigIntegerString.class); + } + + @Override + public BigIntegerString deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + String s = p.readValueAs(String.class); + return new BigIntegerString(new BigInteger(s)); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Blob.java b/src/main/java/com/google/genai/gaos/utils/Blob.java new file mode 100644 index 00000000000..a2136bd82ff --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Blob.java @@ -0,0 +1,316 @@ +/* +* 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.utils; + +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Flow; +import java.util.concurrent.SubmissionPublisher; +import java.util.concurrent.atomic.AtomicBoolean; +import com.google.genai.gaos.utils.reactive.ReactiveUtils; + +/** + * A utility class for creating data blobs from various input sources that implements {@code HttpRequest.BodyPublisher}. + *

+ * This class provides convenient factory methods to create blobs from: + *

    + *
  • File paths ({@link #from(Path)})
  • + *
  • InputStreams ({@link #from(InputStream)})
  • + *
  • Strings ({@link #from(String)})
  • + *
  • Byte arrays ({@link #from(byte[])})
  • + *
  • ByteBuffers ({@link #from(ByteBuffer)})
  • + *
  • Lists of ByteBuffers ({@link #from(List)})
  • + *
  • Reactive publishers ({@link #from(Flow.Publisher)})
  • + *
+ *

+ * Each blob can be used directly as a {@code HttpRequest.BodyPublisher} since this class implements that interface. + *

+ * Additionally, this class provides consumption methods for reactive data processing: + *

    + *
  • Get the stream as a {@code Flow.Publisher} ({@link #asPublisher()})
  • + *
  • Collect the entire stream into a byte array ({@link #toByteArray()})
  • + *
  • Write the stream directly to a file ({@link #toFile(Path)})
  • + *
+ *

+ * Single-use consumption: When using consumption methods ({@code asPublisher()}, {@code toByteArray()}, + * {@code toFile()}), each {@code Blob} instance can only be consumed once. After any consumption method + * is called, the instance is considered consumed and cannot be reused. Any further attempt to use a consumption method + * will result in an {@code IllegalStateException}. + *

+ * Retry compatibility: Most blob types support HTTP request retries effectively. However, InputStream-backed + * blobs ({@link #from(InputStream)}) do not support retries as the stream gets consumed during the first attempt. + * For retry-compatible scenarios, prefer file-based ({@link #from(Path)}) or in-memory ({@link #from(byte[])}) alternatives. + */ +@SuppressWarnings("all") +public class Blob implements HttpRequest.BodyPublisher { + private final Flow.Publisher publisher; + private final long contentLength; + private final AtomicBoolean consumed = new AtomicBoolean(false); // Flag for single-use consumption + + /** + * Private constructor that takes a publisher and content length. + * + * @param publisher the underlying publisher + * @param contentLength the content length, or -1 if unknown + */ + private Blob(Flow.Publisher publisher, long contentLength) { + this.publisher = Objects.requireNonNull(publisher, "Publisher cannot be null"); + this.contentLength = contentLength; + } + + /** + * Creates a {@code Blob} from a file path. + *

+ * This method uses the Java HTTP client's {@code HttpRequest.BodyPublishers.ofFile()} to create + * a reactive publisher from the file content. + * + * @param path the path to the file to read + * @return a new {@code Blob} instance + * @throws FileNotFoundException if the file does not exist or cannot be read + * @throws NullPointerException if {@code path} is {@code null} + */ + public static Blob from(Path path) throws FileNotFoundException { + Objects.requireNonNull(path, "Path cannot be null"); + HttpRequest.BodyPublisher bodyPublisher = HttpRequest.BodyPublishers.ofFile(path); + return new Blob(bodyPublisher, bodyPublisher.contentLength()); + } + + /** + * Creates a {@code Blob} from an {@code InputStream}. + *

+ * This method uses {@code HttpRequest.BodyPublishers.ofInputStream()} to create a reactive + * publisher that reads from the InputStream lazily, avoiding blocking I/O operations. + *

+ * Important: InputStream-backed blobs do not support retries effectively. If the HTTP request + * fails and is retried, the InputStream will have already been consumed during the first attempt, + * causing subsequent retry attempts to send empty request bodies. For retry-compatible scenarios, + * consider using {@link #from(Path)} for file-based data or {@link #from(byte[])} for in-memory data. + * + * @param inputStream the InputStream to read from + * @return a new {@code Blob} instance + * @throws NullPointerException if {@code inputStream} is {@code null} + */ + public static Blob from(InputStream inputStream) { + Objects.requireNonNull(inputStream, "InputStream cannot be null"); + HttpRequest.BodyPublisher bodyPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> inputStream); + return new Blob(bodyPublisher, -1); // Unknown length for InputStream + } + + /** + * Creates a {@code Blob} from a String using UTF-8 encoding. + * + * @param string the string to convert to a Blob + * @return a new {@code Blob} instance + * @throws NullPointerException if {@code string} is {@code null} + */ + public static Blob from(String string) { + Objects.requireNonNull(string, "String cannot be null"); + HttpRequest.BodyPublisher bodyPublisher = HttpRequest.BodyPublishers.ofString(string, StandardCharsets.UTF_8); + return new Blob(bodyPublisher, bodyPublisher.contentLength()); + } + + /** + * Creates a {@code Blob} from a byte array. + *

+ * This method uses HttpRequest.BodyPublishers.ofByteArray(). + * + * @param data the byte array to wrap as a Blob + * @return a new {@code Blob} instance + * @throws NullPointerException if {@code data} is {@code null} + */ + public static Blob from(byte[] data) { + Objects.requireNonNull(data, "Data cannot be null"); + HttpRequest.BodyPublisher bodyPublisher = HttpRequest.BodyPublishers.ofByteArray(data); + return new Blob(bodyPublisher, data.length); // Known length for byte array + } + + /** + * Creates a {@code Blob} from a single {@code ByteBuffer}. + * + * @param buffer the ByteBuffer to wrap as a Blob + * @return a new {@code Blob} instance + * @throws NullPointerException if {@code buffer} is {@code null} + */ + public static Blob from(ByteBuffer buffer) { + Objects.requireNonNull(buffer, "ByteBuffer cannot be null"); + SubmissionPublisher publisher = new SubmissionPublisher<>(); + publisher.submit(buffer.duplicate()); // Use duplicate to avoid modifying original + publisher.close(); + return new Blob(publisher, buffer.remaining()); // Known length from buffer + } + + /** + * Creates a {@code Blob} from a list of {@code ByteBuffer}s. + * + * @param buffers the list of ByteBuffers to wrap as a Blob + * @return a new {@code Blob} instance + * @throws NullPointerException if {@code buffers} is {@code null} + */ + public static Blob from(List buffers) { + Objects.requireNonNull(buffers, "ByteBuffer list cannot be null"); + SubmissionPublisher publisher = new SubmissionPublisher<>(); + + long totalLength = 0; + for (ByteBuffer buffer : buffers) { + publisher.submit(buffer.duplicate()); // Use duplicate to avoid modifying original + totalLength += buffer.remaining(); + } + publisher.close(); + + return new Blob(publisher, totalLength); // Known length from sum of buffer remainings + } + + /** + * Creates a {@code Blob} from a {@code Flow.Publisher>}. + *

+ * This method uses {@code ReactiveUtils.flatten()} to convert the publisher of lists + * into a publisher of individual ByteBuffers. + * + * @param sourcePublisher the publisher that provides data as lists of ByteBuffers + * @return a new {@code Blob} instance + * @throws NullPointerException if {@code sourcePublisher} is {@code null} + */ + public static Blob from(Flow.Publisher> sourcePublisher) { + Objects.requireNonNull(sourcePublisher, "Source publisher cannot be null"); + Flow.Publisher flattenedPublisher = ReactiveUtils.flatten(sourcePublisher); + return new Blob(flattenedPublisher, -1); // Unknown length for reactive publisher + } + + // Consumption methods (single-use) + + /** + * Returns a {@code Flow.Publisher} that emits individual {@code ByteBuffer} + * from the underlying stream. + *

+ * Consumes this instance: After calling this method, this {@code Blob} cannot be used again. + * + * @return a publisher of individual {@code ByteBuffer} items. + * @throws IllegalStateException if this instance has already been consumed. + */ + public Flow.Publisher asPublisher() { + return ensureNotConsumedAndMark(); + } + + /** + * Collects the entire stream into a single byte array. + *

+ * Consumes this instance: After calling this method, this {@code Blob} cannot be used again. + *

+ * The returned {@code CompletableFuture} completes when all data has been received and assembled into the byte array, + * or completes exceptionally if an error occurs. + * + * @return a {@code CompletableFuture} containing the complete byte array. + * @throws IllegalStateException if this instance has already been consumed. + */ + public CompletableFuture toByteArray() { + Flow.Publisher currentPublisher = ensureNotConsumedAndMark(); + + // Convert Flow.Publisher to Flow.Publisher> for BodySubscriber + Flow.Publisher> listPublisher = ReactiveUtils.wrapped(currentPublisher); + + HttpResponse.BodySubscriber bodySubscriber = HttpResponse.BodySubscribers.ofByteArray(); + listPublisher.subscribe(bodySubscriber); + + return bodySubscriber.getBody().toCompletableFuture(); + } + + /** + * Writes the entire stream to the specified file path. + *

+ * Consumes this instance: After calling this method, this {@code Blob} cannot be used again. + *

+ * The returned {@code CompletableFuture} completes with the {@code Path} to the written file when all data + * has been successfully written, or completes exceptionally if an error occurs. + * + * @param destinationPath the path where the stream data will be written. If the file exists, it will be truncated. + * @return a {@code CompletableFuture} containing the {@code Path} to the written file. + * @throws NullPointerException if {@code destinationPath} is {@code null}. + * @throws IllegalStateException if this instance has already been consumed. + */ + public CompletableFuture toFile(Path destinationPath) { + Objects.requireNonNull(destinationPath, "Destination path cannot be null"); + Flow.Publisher currentPublisher = ensureNotConsumedAndMark(); + + // Convert Flow.Publisher to Flow.Publisher> for BodySubscriber + Flow.Publisher> listPublisher = ReactiveUtils.wrapped(currentPublisher); + + HttpResponse.BodySubscriber bodySubscriber = HttpResponse.BodySubscribers.ofFile(destinationPath); + listPublisher.subscribe(bodySubscriber); + + return bodySubscriber.getBody().toCompletableFuture(); + } + + /** + * Converts the entire stream into an {@code InputStream} for traditional I/O operations. + *

+ * Consumes this instance: After calling this method, this {@code Blob} cannot be used again. + *

+ * The returned {@code CompletableFuture} completes with an {@code InputStream} containing all the data + * from the stream when ready, or completes exceptionally if an error occurs. The resulting InputStream + * can be used with traditional Java I/O APIs. + * + * @return a {@code CompletableFuture} containing an {@code InputStream} with the stream data. + * @throws IllegalStateException if this instance has already been consumed. + */ + public CompletableFuture toInputStream() { + Flow.Publisher currentPublisher = ensureNotConsumedAndMark(); + + // Convert Flow.Publisher to Flow.Publisher> for BodySubscriber + Flow.Publisher> listPublisher = ReactiveUtils.wrapped(currentPublisher); + + HttpResponse.BodySubscriber bodySubscriber = HttpResponse.BodySubscribers.ofInputStream(); + listPublisher.subscribe(bodySubscriber); + + return bodySubscriber.getBody().toCompletableFuture(); + } + + /** + * Ensures this instance has not already been consumed, marks it as consumed, and returns the publisher. + * + * @return the {@code Flow.Publisher} to be consumed. + * @throws IllegalStateException if this instance has already been consumed. + */ + private Flow.Publisher ensureNotConsumedAndMark() { + if (!consumed.compareAndSet(false, true)) { + throw new IllegalStateException("This Blob instance has already been consumed and cannot be reused."); + } + return this.publisher; + } + + // HttpRequest.BodyPublisher implementation + + @Override + public long contentLength() { + return contentLength; + } + + @Override + public void subscribe(Flow.Subscriber subscriber) { + publisher.subscribe(subscriber); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/BlockingParser.java b/src/main/java/com/google/genai/gaos/utils/BlockingParser.java new file mode 100644 index 00000000000..502501ee620 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/BlockingParser.java @@ -0,0 +1,102 @@ +/* +* 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.utils; + +import java.io.IOException; +import java.io.Reader; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.Optional; + +/** + * Blocking parser that reads from a Reader and delegates to a StreamingParser. + */ +@SuppressWarnings("all") +public final class BlockingParser { + private final Reader reader; + private final StreamingParser parser; + private final char[] readBuffer = new char[8192]; + private boolean readerExhausted = false; + + public BlockingParser(Reader reader, StreamingParser parser) { + this.reader = reader; + this.parser = parser; + } + + /** + * Read the next parsed result from the Reader. + * + * @return next complete parsed result, or empty if no more data + * @throws IOException if reading fails + */ + public Optional next() throws IOException { + // First check if we already have a complete result buffered + Optional result = parser.next(); + if (result.isPresent()) { + return result; + } + // If reader is exhausted, try to get any remaining partial data + if (readerExhausted) { + return parser.finish(); + } + // Read more data until we have a complete result or EOF + int bytesRead; + while ((bytesRead = reader.read(readBuffer)) != -1) { + ByteBuffer chunk = ByteBuffer.wrap(new String(readBuffer, 0, bytesRead).getBytes(StandardCharsets.UTF_8)); + result = parser.add(chunk); + if (result.isPresent()) { + return result; + } + } + // Reader is now exhausted + readerExhausted = true; + return parser.finish(); + } + + /** + * Check if there are more results available (either buffered or from reader) + */ + public boolean hasNext() throws IOException { + return parser.hasBufferedData() || !readerExhausted; + } + + /** + * Close the underlying reader + */ + public void close() throws IOException { + reader.close(); + } + + // ===== Factory Methods ===== + + /** + * Create a blocking parser for JSON Lines format + */ + public static BlockingParser forJsonLines(Reader reader) { + return new BlockingParser<>(reader, StreamingParser.forJsonLines()); + } + + /** + * Create a blocking parser for SSE format + */ + public static BlockingParser forSSE(Reader reader) { + return new BlockingParser<>(reader, StreamingParser.forSSE()); + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/Constants.java b/src/main/java/com/google/genai/gaos/utils/Constants.java new file mode 100644 index 00000000000..d29fcc62e7a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Constants.java @@ -0,0 +1,27 @@ +/* +* 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.utils; + +@SuppressWarnings("all") +public final class Constants { + + public static final boolean HAS_CLIENT_CREDENTIALS_BASIC = false; + +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/CopiableInputStream.java b/src/main/java/com/google/genai/gaos/utils/CopiableInputStream.java new file mode 100644 index 00000000000..76a0b86c7ab --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/CopiableInputStream.java @@ -0,0 +1,43 @@ +/* +* 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.utils; + +import org.apache.commons.io.IOUtils; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +@SuppressWarnings("all") +public class CopiableInputStream { + private final byte[] bytes; + + public CopiableInputStream(InputStream original) { + try (InputStream stream = original) { + this.bytes = IOUtils.toByteArray(stream); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public InputStream copy() { + return new ByteArrayInputStream(bytes); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Deserializers.java b/src/main/java/com/google/genai/gaos/utils/Deserializers.java new file mode 100644 index 00000000000..5ad036f2c1d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Deserializers.java @@ -0,0 +1,257 @@ +/* +* 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.utils; + +import java.io.IOException; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; + +@SuppressWarnings("all") +public final class Deserializers { + + public static final JsonDeserializer BOOLEAN_STRICT = new StrictBooleanDeserializer(); + public static final JsonDeserializer INTEGER_STRICT = new StrictIntegerDeserializer(); + public static final JsonDeserializer LONG_STRICT = new StrictLongDeserializer(); + public static final JsonDeserializer SHORT_STRICT = new StrictShortDeserializer(); + public static final JsonDeserializer FLOAT_STRICT = new StrictFloatDeserializer(); + public static final JsonDeserializer DOUBLE_STRICT = new StrictDoubleDeserializer(); + public static final JsonDeserializer LOCAL_DATE_STRICT = new StrictLocalDateDeserializer(); + public static final JsonDeserializer OFFSET_DATE_TIME_STRICT = new StrictOffsetDateTimeDeserializer(); + public static final JsonDeserializer STRING_STRICT = new StrictStringDeserializer(); + + public static final Module STRICT_DESERIALIZERS = createStrictDeserializersModule(); + + private static Module createStrictDeserializersModule() { + SimpleModule m = new SimpleModule(); + m.addDeserializer(Boolean.class, Deserializers.BOOLEAN_STRICT); + m.addDeserializer(Short.class, Deserializers.SHORT_STRICT); + m.addDeserializer(Integer.class, Deserializers.INTEGER_STRICT); + m.addDeserializer(Long.class, Deserializers.LONG_STRICT); + m.addDeserializer(Float.class, Deserializers.FLOAT_STRICT); + m.addDeserializer(Double.class, Deserializers.DOUBLE_STRICT); + m.addDeserializer(OffsetDateTime.class, Deserializers.OFFSET_DATE_TIME_STRICT); + m.addDeserializer(LocalDate.class, Deserializers.LOCAL_DATE_STRICT); + m.addDeserializer(String.class, Deserializers.STRING_STRICT); + return m; + } + + private static final class StrictBooleanDeserializer extends StdDeserializer { + + private static final long serialVersionUID = 6014987192625841276L; + + StrictBooleanDeserializer() { + super(Boolean.class); + } + + @Override + public Boolean deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + JsonToken t = p.currentToken(); + if (t == JsonToken.VALUE_TRUE) { + return true; + } else if (t == JsonToken.VALUE_FALSE) { + return false; + } else { + return (Boolean) ctxt.handleUnexpectedToken(Boolean.class, p); + } + } + } + + private static final class StrictDoubleDeserializer extends StdDeserializer { + + private static final long serialVersionUID = 5500822592284739392L; + + StrictDoubleDeserializer() { + super(Double.class); + } + + @Override + public Double deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + JsonToken t = p.currentToken(); + if (t == JsonToken.VALUE_NUMBER_INT) { + return p.getDoubleValue(); + } else if (t == JsonToken.VALUE_NUMBER_FLOAT) { + return p.getDoubleValue(); + } else { + return (Double) ctxt.handleUnexpectedToken(Double.class, p); + } + } + } + + private static final class StrictFloatDeserializer extends StdDeserializer { + + private static final long serialVersionUID = 2207323065789635630L; + + StrictFloatDeserializer() { + super(Float.class); + } + + @Override + public Float deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + JsonToken t = p.currentToken(); + if (t == JsonToken.VALUE_NUMBER_INT) { + return p.getFloatValue(); + } else if (t == JsonToken.VALUE_NUMBER_FLOAT) { + return p.getFloatValue(); + } else { + return (Float) ctxt.handleUnexpectedToken(Float.class, p); + } + } + } + + private static final class StrictIntegerDeserializer extends StdDeserializer { + + private static final long serialVersionUID = 6079282945607228350L; + + StrictIntegerDeserializer() { + super(Integer.class); + } + + @Override + public Integer deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + JsonToken t = p.currentToken(); + if (t == JsonToken.VALUE_NUMBER_INT) { + return p.getIntValue(); + } else { + return (Integer) ctxt.handleUnexpectedToken(Integer.class, p); + } + } + } + + private static final class StrictLocalDateDeserializer extends StdDeserializer { + + private static final long serialVersionUID = 6014987192625841276L; + + StrictLocalDateDeserializer() { + super(LocalDate.class); + } + + @Override + public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException { + if (p.currentToken() == JsonToken.VALUE_STRING) { + String text = p.getText(); + try { + return LocalDate.parse(text, DateTimeFormatter.ISO_LOCAL_DATE); + } catch (DateTimeParseException e) { + return (LocalDate) ctxt.handleWeirdStringValue(LocalDate.class, text, e.getMessage()); + } + } else { + return (LocalDate) ctxt.handleUnexpectedToken(LocalDate.class, p); + } + } + } + + private static final class StrictLongDeserializer extends StdDeserializer { + + private static final long serialVersionUID = -2721538755854421632L; + + public StrictLongDeserializer() { + super(Long.class); + } + + @Override + public Long deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + JsonToken t = p.currentToken(); + if (t == JsonToken.VALUE_NUMBER_INT) { + return p.getLongValue(); + } else { + return (Long) ctxt.handleUnexpectedToken(Long.class, p); + } + } + } + + private static final class StrictOffsetDateTimeDeserializer extends StdDeserializer { + + private static final long serialVersionUID = 6014987192625841276L; + + StrictOffsetDateTimeDeserializer() { + super(OffsetDateTime.class); + } + + @Override + public OffsetDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException { + if (p.currentToken() == JsonToken.VALUE_STRING) { + String text = p.getText(); + try { + return OffsetDateTime.parse(text, DateTimeFormatter.ISO_DATE_TIME); + } catch (DateTimeParseException e) { + return (OffsetDateTime) ctxt.handleWeirdStringValue(OffsetDateTime.class, text, e.getMessage()); + } + } else { + return (OffsetDateTime) ctxt.handleUnexpectedToken(OffsetDateTime.class, p); + } + } + } + + private static final class StrictShortDeserializer extends StdDeserializer { + + private static final long serialVersionUID = 2162877248512421L; + + StrictShortDeserializer() { + super(Short.class); + } + + @Override + public Short deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + JsonToken t = p.currentToken(); + if (t == JsonToken.VALUE_NUMBER_INT) { + return p.getShortValue(); + } else { + return (Short) ctxt.handleUnexpectedToken(Short.class, p); + } + } + } + + private static final class StrictStringDeserializer extends StdDeserializer { + + private static final long serialVersionUID = 6014987192625841276L; + + StrictStringDeserializer() { + super(String.class); + } + + @Override + public String deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JacksonException { + JsonToken t = p.currentToken(); + if (t == JsonToken.VALUE_STRING) { + return p.getText(); + } else { + return (String) ctxt.handleUnexpectedToken(String.class, p); + } + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/EventStream.java b/src/main/java/com/google/genai/gaos/utils/EventStream.java new file mode 100644 index 00000000000..a110c3228e1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/EventStream.java @@ -0,0 +1,248 @@ +/* +* 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.utils; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +/** + * Provides a convenient way to consume Server-Sent Events (SSE) from a stream. + *

+ * Each SSE message's {@code data} field is deserialized into the type {@code T}, + * allowing for easy processing of events as domain objects. + *

+ * + *

Event Consumption

+ *

Events can be consumed in multiple ways:

+ * + *
    + *
  • Iteration: Use a for-each loop to process each event:
  • + *
+ *
{@code
+ * try (EventStream eventStream = new EventStream<>(...)) {
+ *     for (MyEvent event : eventStream) {
+ *         handleEvent(event);
+ *     }
+ * }
+ * }
+ * + *
    + *
  • Stream API: Consume events as a Java Stream (must be closed after use):
  • + *
+ *
{@code
+ * try (EventStream eventStream = new EventStream<>(...);
+ *      Stream stream = eventStream.stream()) {
+ *     stream.forEach(this::handleEvent);
+ * }
+ * }
+ * + *
    + *
  • Collect to List: Read all remaining events into a list:
  • + *
+ *
{@code
+ * try (EventStream eventStream = new EventStream<>(...)) {
+ *     List events = eventStream.toList();
+ * }
+ * }
+ * + *

+ * Events are lazily loaded from the underlying SSE stream. Consumption stops either + * when the stream ends or when an optional terminal message is encountered. + *

+ * + *

+ * Important: This class implements {@link AutoCloseable} and must be used + * within a try-with-resources block to ensure that underlying streams are + * properly closed after consumption, preventing resource leaks. + *

+ * + * @param the type that SSE {@code data} fields will be deserialized into + */ +@SuppressWarnings("all") +public final class EventStream implements Iterable, AutoCloseable { + + private static final SpeakeasyLogger logger = SpeakeasyLogger.getLogger(EventStream.class); + + private final BlockingParser parser; + private final TypeReference typeReference; + private final ObjectMapper mapper; + private final Optional terminalMessage; + private final boolean dataRequired; + private boolean terminated = false; + private boolean closed = false; + + // Internal use only + public EventStream(InputStream in, TypeReference typeReference, ObjectMapper mapper, Optional terminalMessage) { + this(in, typeReference, mapper, terminalMessage, true); + } + + // Internal use only + public EventStream(InputStream in, TypeReference typeReference, ObjectMapper mapper, Optional terminalMessage, boolean dataRequired) { + BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8), 8192); + this.parser = BlockingParser.forSSE(reader); + this.typeReference = typeReference; + this.mapper = mapper; + this.terminalMessage = terminalMessage; + this.dataRequired = dataRequired; + logger.debug("EventStream initialized for type: {}", typeReference.getType().getTypeName()); + } + + /** + * Returns the next message. If another message does not exist returns + * {@code Optional.empty()}. + * + * @return the next message or {@code Optional.empty()} if no more messages + * @throws IOException when parsing the next message. + */ + public Optional next() throws IOException { + while (!terminated) { + Optional message = parser.next(); + if (message.isEmpty()) { + terminated = true; + return Optional.empty(); + } + EventStreamMessage msg = message.get(); + boolean isTerminal = terminalMessage.flatMap(sentinel -> msg.data().map(sentinel::equals)).orElse(false); + if (isTerminal) { + terminated = true; + if (logger.isTraceEnabled()) { + logger.trace("Terminal message encountered in EventStream"); + } + return Optional.empty(); + } + // Skip events without data when data is required + if (dataRequired && msg.data().isEmpty()) { + if (logger.isTraceEnabled()) { + logger.trace("Skipping SSE event with no data field"); + } + continue; + } + Optional result = Optional.of(Utils.asType(msg, mapper, typeReference)); + if (logger.isTraceEnabled()) { + logger.trace("EventStream item processed"); + } + return result; + } + return Optional.empty(); + } + + /** + * Reads all events and returns them as a {@code List}. This method calls + * {@code close()}. + * + * @return list of events + */ + public List toList() { + try { + return stream().collect(Collectors.toList()); + } finally { + try { + close(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * Returns an {@link Iterator} of {@link T} events, enabling iteration via for-each loops. + * + * @return events iterator. + */ + @Override + public Iterator iterator() { + return new EventIterator<>(this); + } + + /** + * Returns a {@link Stream} of events. Must be closed after use! + * + * @return streamed events + */ + public Stream stream() { + return StreamSupport.stream( + Spliterators.spliteratorUnknownSize( + iterator(), + Spliterator.ORDERED), false) + .onClose(() -> { + try { + EventStream.this.close(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } + + @Override + public void close() throws IOException { + closed = true; + logger.debug("EventStream closed"); + parser.close(); + } + + public boolean isClosed() { + return closed; + } + + static class EventIterator implements Iterator { + private final EventStream stream; + private Optional next = Optional.empty(); + + EventIterator(EventStream stream) { + this.stream = stream; + } + + public T next() { + load(); + if (next.isEmpty()) { + throw new NoSuchElementException(); + } + T v = next.get(); + next = Optional.empty(); + return v; + } + + public boolean hasNext() { + load(); + return next.isPresent(); + } + + private void load() { + if (next.isEmpty()) { + try { + next = stream.next(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/EventStreamMessage.java b/src/main/java/com/google/genai/gaos/utils/EventStreamMessage.java new file mode 100644 index 00000000000..5f68ae75d8e --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/EventStreamMessage.java @@ -0,0 +1,68 @@ +/* +* 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.utils; + +import java.util.Optional; + +@SuppressWarnings("all") +public class EventStreamMessage { + + private final Optional event; + private final Optional id; + private final Optional retryMs; + private final Optional data; + + public EventStreamMessage(Optional event, Optional id, Optional retryMs, Optional data) { + this.event = event; + this.id = id; + this.retryMs = retryMs; + this.data = data; + } + + public Optional event() { + return event; + } + + public Optional id() { + return id; + } + + public Optional retryMs() { + return retryMs; + } + + public Optional data() { + return data; + } + + public boolean isEmpty() { + return !event.isPresent() && !id().isPresent() && !retryMs().isPresent() && !data.isPresent(); + } + + @Override + public String toString() { + StringBuilder b = new StringBuilder(); + event.ifPresent(value -> b.append("event: " + value + "\n")); + id.ifPresent(value -> b.append("id: " + value + "\n")); + retryMs.ifPresent(value -> b.append("retry: " + value + "\n")); + data.ifPresent(value -> b.append("data: " + value)); + return b.toString(); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Exceptions.java b/src/main/java/com/google/genai/gaos/utils/Exceptions.java new file mode 100644 index 00000000000..667c9846813 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Exceptions.java @@ -0,0 +1,112 @@ +/* +* 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.utils; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import java.io.IOException; +import java.io.UncheckedIOException; + +@SuppressWarnings("all") +public class Exceptions { + public static Exception coerceException(Throwable throwable) { + if (throwable instanceof Exception) { + return (Exception) throwable; + } + + return new Exception(throwable); + } + + public static RuntimeException unchecked(Throwable t) { + if (t instanceof RuntimeException) { + return (RuntimeException) t; + } else if (t instanceof Error) { + throw (Error) t; // propagate JVM-level errors properly + } else if (t instanceof IOException) { + throw new UncheckedIOException((IOException) t); + } else { + throw new RuntimeException(t); + } + } + + public static T rethrow(Throwable e) { + throw unchecked(e); + } + + @FunctionalInterface + public interface CheckedFunction { + R apply(T t) throws Exception; + } + + @FunctionalInterface + public interface CheckedSupplier { + T get() throws Exception; + } + + @FunctionalInterface + public interface CheckedConsumer { + void accept(T t) throws Exception; + } + + @FunctionalInterface + public interface CheckedRunnable { + void run() throws Exception; + } + + public static Function unchecked(CheckedFunction fn) { + return t -> { + try { + return fn.apply(t); + } catch (Exception e) { + throw unchecked(e); + } + }; + } + + public static Supplier unchecked(CheckedSupplier supplier) { + return () -> { + try { + return supplier.get(); + } catch (Exception e) { + throw unchecked(e); + } + }; + } + + public static Consumer unchecked(CheckedConsumer consumer) { + return t -> { + try { + consumer.accept(t); + } catch (Exception e) { + throw unchecked(e); + } + }; + } + + public static Runnable unchecked(CheckedRunnable runnable) { + return () -> { + try { + runnable.run(); + } catch (Exception e) { + throw unchecked(e); + } + }; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/FormMetadata.java b/src/main/java/com/google/genai/gaos/utils/FormMetadata.java new file mode 100644 index 00000000000..c16fce94874 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/FormMetadata.java @@ -0,0 +1,39 @@ +/* +* 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.utils; + +import java.lang.reflect.Field; + +@SuppressWarnings("all") +class FormMetadata { + + String style = "form"; + boolean explode = true; + boolean json; + String name; + + private FormMetadata() { + } + + // form:name=propName,style=spaceDelimited,explode=true + static FormMetadata parse(Field field) throws IllegalArgumentException, IllegalAccessException { + return Metadata.parse("form", new FormMetadata(), field); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/GenericTypeIdResolver.java b/src/main/java/com/google/genai/gaos/utils/GenericTypeIdResolver.java new file mode 100644 index 00000000000..9ccc35929c1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/GenericTypeIdResolver.java @@ -0,0 +1,66 @@ +/* +* 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.utils; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.databind.DatabindContext; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Generic type resolver that supports both manual type registration and automatic + * fallback to unknown types for unrecognized discriminator values. + */ +@SuppressWarnings("all") +public abstract class GenericTypeIdResolver extends TypeIdResolverBase { + private final Map> typeMap = new HashMap<>(); + protected final Class unknownType; + + protected GenericTypeIdResolver(Class unknownType) { + this.unknownType = unknownType; + } + + protected void registerType(String typeId, Class clazz) { + typeMap.put(typeId, clazz); + } + + @Override + public String idFromValueAndType(Object value, Class suggestedType) { + return idFromValue(value); + } + + @Override + public JsonTypeInfo.Id getMechanism() { + return JsonTypeInfo.Id.CUSTOM; + } + + @Override + public JavaType typeFromId(DatabindContext context, String id) throws IOException { + Class targetClass = typeMap.get(id); + if (targetClass != null) { + return context.constructType(targetClass); + } + return context.constructType(unknownType); + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/Globals.java b/src/main/java/com/google/genai/gaos/utils/Globals.java new file mode 100644 index 00000000000..671490ecea0 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Globals.java @@ -0,0 +1,106 @@ +/* +* 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.utils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.stream.Stream; + +@SuppressWarnings("all") +public final class Globals { + + private final Map queryParams = new HashMap<>(); + private final Map pathParams = new HashMap<>(); + private final Map headerParams = new HashMap<>(); + + + public Globals() { + } + + // internal use only + public void putParam(String type, String name, Object value) { + if ("pathParam".equals(type)) { + putPathParam(name, value); + } else if ("queryParam".equals(type)) { + putQueryParam(name, value); + } else if ("header".equals(type)) { + putHeader(name, value); + } else { + throw new IllegalArgumentException("Unknown parameter type: " + type); + } + } + + // internal use only + public Optional getParam(String type, String name) { + if ("pathParam".equals(type)){ + return getPathParam(name); + } else if ("queryParam".equals(type)) { + return getQueryParam(name); + } else if ("header".equals(type)) { + return getHeader(name); + } else { + throw new IllegalArgumentException("Unknown parameter type: " + type); + } + } + + public void putQueryParam(String name, Object value) { + if (value != null) { + queryParams.put(name, Utils.valToString(value)); + } + } + + public void putPathParam(String name, Object value) { + if (value != null) { + pathParams.put(name, Utils.valToString(value)); + } + } + + public void putHeader(String name, Object value) { + if (value != null) { + headerParams.put(name, Utils.valToString(value)); + } + } + + public Optional getQueryParam(String name) { + return Optional.ofNullable(queryParams.get(name)); + } + + public Optional getPathParam(String name) { + return Optional.ofNullable(pathParams.get(name)); + } + + public Optional getHeader(String name) { + return Optional.ofNullable(headerParams.get(name)); + } + + public Stream> queryParamsAsStream() { + return queryParams.entrySet().stream(); + } + + public Stream> pathParamsAsStream() { + return pathParams.entrySet().stream(); + } + + public Stream> headerParamsAsStream() { + return headerParams.entrySet().stream(); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/HTTPClient.java b/src/main/java/com/google/genai/gaos/utils/HTTPClient.java new file mode 100644 index 00000000000..9d39a089948 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/HTTPClient.java @@ -0,0 +1,103 @@ +/* +* 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.utils; + +import com.google.genai.gaos.utils.Blob; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public interface HTTPClient { + HttpClient client = HttpClient.newHttpClient(); + + /** + * Sends an HTTP request and returns the response. + * + *

+ * Note that {@link HttpRequest} is immutable. To modify the request you can + * use + * {@code HttpRequest#newBuilder(HttpRequest, BiPredicate)} + * with JDK 16 and later (which will copy the request for modification in a + * builder). If that method is not available then use {@link Helpers#copy} + * (which also returns a builder). + * + * @param request HTTP request + * @return HTTP response + * @throws IOException + * @throws InterruptedException + * @throws URISyntaxException + */ + default HttpResponse send(HttpRequest request) + throws IOException, InterruptedException, URISyntaxException { + return client.send(request, HttpResponse.BodyHandlers.ofInputStream()); + } + + /** + * Sends an HTTP request asynchronously and returns a response whose body is + * exposed as a {@link Blob}. + *

+ * This method uses the {@code HttpResponse.BodyHandlers.ofPublisher()} to + * obtain the response body as a {@code Flow.Publisher>}, + * which is then wrapped in a {@code Blob} for non-blocking, + * reactive consumption of the response data. + *

+ * The returned {@code CompletableFuture} completes when the response is + * received, or completes exceptionally if an error occurs during the + * request or response processing. + * + * @param request the HTTP request to send + * @return a {@code CompletableFuture} containing the HTTP response with a + * {@code Blob} body + */ + default CompletableFuture> sendAsync( + HttpRequest request) { + return client.sendAsync(request, HttpResponse.BodyHandlers.ofPublisher()) + .thenApply(resp -> + new ResponseWithBody<>(resp, Blob::from)); + } + + /** + * Controls the debug flag that can be used by clients to perform conditional + * debugging actions like logging HTTP requests and responses. + * This is currently implemented in SpeakeasyHTTPClient but custom client + * implementations are free to use this method similarly if they wish. + * + * @param enabled Whether to enable debug flag + */ + default void enableDebugLogging(boolean enabled) { + // do nothing + } + + /** + * Returns whether debug logging is enabled. + * + * @return Whether debug logging is enabled + */ + default boolean isDebugLoggingEnabled() { + return false; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/HTTPRequest.java b/src/main/java/com/google/genai/gaos/utils/HTTPRequest.java new file mode 100644 index 00000000000..c7eaea6ac75 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/HTTPRequest.java @@ -0,0 +1,148 @@ +/* +* 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.utils; + +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@SuppressWarnings("all") +public class HTTPRequest { + + private static final String FRAGMENT_SEGMENT_START = "#"; + private static final String QUERY_NAME_VALUE_DELIMITER = "="; + private static final String QUERY_PARAMETER_DELIMITER = "&"; + private static final String QUERY_SEGMENT_START = "?"; + private final String baseURL; + private final String method; + private final List queryParams = new ArrayList<>(); + private final Map> headers = new HashMap<>(); + private Optional body = Optional.empty(); // mutable + + public HTTPRequest(String baseURL, String method) { + Utils.checkNotNull(baseURL, "baseURL"); + Utils.checkNotNull(method, "method"); + this.baseURL = baseURL; + this.method = method; + } + + public void setBody(Optional body) { + Utils.checkNotNull(body, "body"); + this.body = body; + } + + public HTTPRequest addHeader(String key, String value) { + List headerValues = headers.get(key); + if (headerValues == null) { + headerValues = new ArrayList<>(); + headers.put(key, headerValues); + } + if (!headerValues.contains(value)) { + headerValues.add(value); + } + return this; + } + + public HTTPRequest addHeaders(Map> map) { + map.forEach((key, list) -> list.forEach(v -> addHeader(key, v))); + return this; + } + + public HTTPRequest addQueryParam(QueryParameter param) { + this.queryParams.add(param); + return this; + } + + public HTTPRequest addQueryParam(String key, String value, boolean allowReserved) { + this.queryParams.add(QueryParameter.of(key, value, allowReserved)); + return this; + } + + public HTTPRequest addQueryParams(Collection params) { + params.forEach(p -> addQueryParam(p)); + return this; + } + + public HttpRequest build() { + HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(); + + final BodyPublisher bodyPublisher; + if (body.isPresent()) { + bodyPublisher = body.get().body(); + requestBuilder.header("Content-Type", body.get().contentType()); + } else { + bodyPublisher = BodyPublishers.noBody(); + } + requestBuilder.method(method, bodyPublisher); + try { + requestBuilder.uri(new URI(buildUrl(baseURL, queryParams))); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + headers.forEach((k, list) -> list.forEach(v -> requestBuilder.header(k, v))); + return requestBuilder.build(); + } + + // VisibleForTesting + public static String buildUrl(String baseURL, Collection queryParams) { + if (queryParams.isEmpty()) { + return baseURL; + } else { + final String base; + final String fragment; + int i = baseURL.indexOf(FRAGMENT_SEGMENT_START); + if (i == -1) { + base = baseURL; + fragment = ""; + } else { + base = baseURL.substring(0, i); + fragment = baseURL.substring(i); + } + StringBuilder b = new StringBuilder(base); + if (!base.contains(QUERY_SEGMENT_START)) { + b.append(QUERY_SEGMENT_START); + } else { + b.append(QUERY_PARAMETER_DELIMITER); + } + boolean first = true; + for (QueryParameter p : queryParams) { + if (!first) { + b.append(QUERY_PARAMETER_DELIMITER); + } + first = false; + // don't allow reserved characters to be unencoded in key (??) + b.append(Utf8UrlEncoder.DEFAULT.encode(p.name())); + b.append(QUERY_NAME_VALUE_DELIMITER); + b.append(Utf8UrlEncoder.allowReserved(p.allowReserved()).encode(p.value())); + } + b.append(fragment); + return b.toString(); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/HasSecurity.java b/src/main/java/com/google/genai/gaos/utils/HasSecurity.java new file mode 100644 index 00000000000..813dd70f3d6 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/HasSecurity.java @@ -0,0 +1,27 @@ +/* +* 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.utils; + +/** + * Implemented by classes that have security annotations on fields. + **/ +@SuppressWarnings("all") +public interface HasSecurity { +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/HeaderMetadata.java b/src/main/java/com/google/genai/gaos/utils/HeaderMetadata.java new file mode 100644 index 00000000000..4616511fc5c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/HeaderMetadata.java @@ -0,0 +1,38 @@ +/* +* 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.utils; + +import java.lang.reflect.Field; + +@SuppressWarnings("all") +class HeaderMetadata { + + String style = "simple"; + boolean explode; + String name; + + private HeaderMetadata() { + } + + // headerParam:style=simple,explode=false,name=apiID + static HeaderMetadata parse(Field field) throws IllegalArgumentException, IllegalAccessException { + return Metadata.parse("header", new HeaderMetadata(), field); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Headers.java b/src/main/java/com/google/genai/gaos/utils/Headers.java new file mode 100644 index 00000000000..4388c5be196 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Headers.java @@ -0,0 +1,140 @@ +/* +* 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.utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.Locale; +import java.util.function.BiConsumer; + +// Internal API only + +/** + * Encapsulates HTTP headers. Header names are case-insensitive. + */ +@SuppressWarnings("all") +public final class Headers { + + public static final Headers EMPTY = new Headers(Collections.emptyMap()); + + // keys are lowercased + private final Map> map; + + // Internal use only + public Headers(Map> headers) { + Utils.checkNotNull(headers, "headers"); + this.map = headers // + .entrySet() // + .stream() // + .map(entry -> Map.entry(entry.getKey().toLowerCase(Locale.ENGLISH), entry.getValue())) // + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + + // Internal use only + public Headers() { + this(new HashMap<>()); + } + + /** + * Returns all values for a header name. Header name is case-insensitive. + * + * @param name header name + * @return all values for the header name + */ + public List get(String name) { + Utils.checkNotNull(name, "name"); + return Collections.unmodifiableList(values(name)); + } + + /** + * Returns the first value for a header name. Header name is case-insensitive. + * + * @param name header name + * @return the first value for the header name + */ + public Optional first(String name) { + Utils.checkNotNull(name, "name"); + return values(name).stream().findFirst(); + } + + /** + * Appends a header value. Header name is case-insensitive. + * + * @param name header name + * @param value header value + * @return this + */ + public Headers add(String name, String value) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(value, "value"); + List values = values(name); + if (values.isEmpty()) { + List list = new ArrayList<>(); + list.add(value); + map.put(name.toLowerCase(Locale.ENGLISH), list); + } else { + values.add(value); + } + return this; + } + + public Headers add(Headers headers) { + Utils.checkNotNull(headers, "headers"); + headers + .forEach((key, values) -> values.forEach(value -> add(key, value))); + return this; + } + + public void forEach(BiConsumer> consumer) { + Utils.checkNotNull(consumer, "consumer"); + map.forEach(consumer); + } + + /** + * Returns a copy of the headers as a map. Header names are lowercase. + * + * @return headers as a map + */ + public Map> map() { + return map // + .entrySet() // + .stream() // + .collect(Collectors.toMap(Map.Entry::getKey, entry -> new ArrayList<>(entry.getValue()))); + } + + private List values(String name) { + return map.getOrDefault(name.toLowerCase(Locale.ENGLISH), List.of()); + } + + @Override + public String toString() { + return "Headers[ " // + + map.entrySet() // + .stream() // + .map(entry -> entry.getKey() + "=" + entry.getValue()) // + .collect(Collectors.joining(", ")) // + + "]"; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Helpers.java b/src/main/java/com/google/genai/gaos/utils/Helpers.java new file mode 100644 index 00000000000..b72a8e5d6fa --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Helpers.java @@ -0,0 +1,144 @@ +/* +* 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.utils; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.http.HttpRequest; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Flow; +import java.util.concurrent.TimeUnit; +import java.util.function.BiPredicate; + +/** + * Public helper methods for use by customers and end-users. + * + */ +@SuppressWarnings("all") +public final class Helpers { + + /** + * Returns an {@link HttpRequest.Builder} which is initialized with the + * state of the given {@link HttpRequest}. + * + *

Note that headers can be added and modified but not removed. To + * remove headers use {@link #copy(HttpRequest, BiPredicate)} (which applies + * a filter to the headers while copying). + * + *

Note also that this method is redundant from JDK 16 because the + * method {@code HttpRequest.newBuilder(HttpRequest)} is available. + * + * @param request request to copy + * @return a builder initialized with values from {@code request} + */ + public static HttpRequest.Builder copy(HttpRequest request) { + return Utils.copy(request); + } + + /** + * Returns an {@link HttpRequest.Builder} which is initialized with the + * state of the given {@link HttpRequest}. + * + *

Note that this method is redundant from JDK 16 because the + * method {@code HttpRequest.newBuilder(HttpRequest, BiPredicate)} is available. + + * @param request request to copy + * @param filter selects which header key-values to include in the copied request + * @return a builder initialized with values from {@code request} + */ + public static HttpRequest.Builder copy(HttpRequest request, BiPredicate filter) { + return Utils.copy(request, filter); + } + + + /** + * Returns the request body as a byte array. + * + * @param request http request to extract from + * @return byte array + */ + public static byte[] bodyBytes(HttpRequest request) { + return request.bodyPublisher() // + .map(p -> { + ByteBufferSubscriber sub = new ByteBufferSubscriber(); + p.subscribe(sub); + return sub.bytes(); + }).orElse(new byte[] {}); + } + + /** + * Returns the request body as a String assuming that the bytes of the request + * body are encoded with UTF-8. + * + * @param request http request to extract from + * @return request body as a String + */ + public static String bodyUtf8(HttpRequest request) { + return new String(bodyBytes(request), StandardCharsets.UTF_8); + } + + private static final class ByteBufferSubscriber implements Flow.Subscriber { + + private final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + private final CountDownLatch latch = new CountDownLatch(1); + + @Override + public void onSubscribe(Flow.Subscription subscription) { + // Retrieve all parts + subscription.request(Long.MAX_VALUE); + } + + @Override + public void onNext(ByteBuffer bb) { + byte[] buffer = new byte[bb.remaining()]; + bb.get(buffer); + try { + bytes.write(buffer); + } catch (IOException e) { + onError(e); + } + } + + @Override + public void onError(Throwable throwable) { + latch.countDown(); + Exceptions.rethrow(throwable); + } + + @Override + public void onComplete() { + latch.countDown(); + } + + public byte[] bytes() { + try { + if (!latch.await(30, TimeUnit.SECONDS)) { + throw new RuntimeException("timed out waiting for next byte array"); + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return bytes.toByteArray(); + } + } + +} diff --git a/src/main/java/com/google/genai/gaos/utils/Hook.java b/src/main/java/com/google/genai/gaos/utils/Hook.java new file mode 100644 index 00000000000..5992209b0de --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Hook.java @@ -0,0 +1,334 @@ +/* +* 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.utils; + +import java.io.InputStream; +import java.net.http.HttpResponse; +import java.net.http.HttpRequest; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.SecuritySource; + +/** + * Holder class for hook-associated types. This class does not get + * instantiated. + */ +@SuppressWarnings("all") +public final class Hook { + + private Hook() { + // prevent instantiation + } + + /** + * Context for a hook call. + */ + public interface HookContext { + SDKConfiguration sdkConfiguration(); + String baseUrl(); + String operationId(); + Optional> oauthScopes(); + Optional securitySource(); + } + + /** + * Context for a BeforeRequest hook call. + */ + public interface BeforeRequestContext extends HookContext { + } + + public static final class BeforeRequestContextImpl implements BeforeRequestContext { + + private final SDKConfiguration sdkConfiguration; + private final String baseUrl; + private final String operationId; + private final Optional> oauthScopes; + private final Optional securitySource; + + public BeforeRequestContextImpl(SDKConfiguration sdkConfiguration, String baseUrl, String operationId, Optional> oauthScopes, Optional securitySource) { + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = baseUrl; + this.operationId = operationId; + this.oauthScopes = oauthScopes; + this.securitySource = securitySource; + } + + @Override + public SDKConfiguration sdkConfiguration() { + return sdkConfiguration; + } + + @Override + public String baseUrl() { + return baseUrl; + } + + @Override + public String operationId() { + return operationId; + } + + @Override + public Optional securitySource() { + return securitySource; + } + + @Override + public Optional> oauthScopes() { + return oauthScopes; + } + } + + /** + * Context for an AfterSuccess hook call. + */ + public interface AfterSuccessContext extends HookContext { + } + + public static final class AfterSuccessContextImpl implements AfterSuccessContext { + + private final SDKConfiguration sdkConfiguration; + private final String baseUrl; + private final String operationId; + private final Optional> oauthScopes; + private final Optional securitySource; + + public AfterSuccessContextImpl(SDKConfiguration sdkConfiguration, String baseUrl, String operationId, Optional> oauthScopes, Optional securitySource) { + Utils.checkNotNull(securitySource, "securitySource"); + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = baseUrl; + this.operationId = operationId; + this.oauthScopes = oauthScopes; + this.securitySource = securitySource; + } + + @Override + public SDKConfiguration sdkConfiguration() { + return sdkConfiguration; + } + + @Override + public String baseUrl() { + return baseUrl; + } + + @Override + public String operationId() { + return operationId; + } + + @Override + public Optional securitySource() { + return securitySource; + } + + @Override + public Optional> oauthScopes() { + return oauthScopes; + } + } + + /** + * Context for an AfterError hook call. + */ + public interface AfterErrorContext extends HookContext { + } + + public static final class AfterErrorContextImpl implements AfterErrorContext { + + private final SDKConfiguration sdkConfiguration; + private final String baseUrl; + private final String operationId; + private final Optional> oauthScopes; + private final Optional securitySource; + + public AfterErrorContextImpl(SDKConfiguration sdkConfiguration, String baseUrl, String operationId, Optional> oauthScopes, Optional securitySource) { + Utils.checkNotNull(securitySource, "securitySource"); + this.sdkConfiguration = sdkConfiguration; + this.baseUrl = baseUrl; + this.operationId = operationId; + this.oauthScopes = oauthScopes; + this.securitySource = securitySource; + } + + @Override + public SDKConfiguration sdkConfiguration() { + return sdkConfiguration; + } + + @Override + public String baseUrl() { + return baseUrl; + } + + @Override + public String operationId() { + return operationId; + } + + @Override + public Optional securitySource() { + return securitySource; + } + + @Override + public Optional> oauthScopes() { + return oauthScopes; + } + } + + /** + * Specifies how a request is transformed before sending. + */ + public interface BeforeRequest { + + /** + * Transforms the given {@link HttpRequest} before sending. + * + *

Note that {@link HttpRequest} is immutable. To modify the request you can use + * {@code HttpRequest#newBuilder(HttpRequest, BiPredicate)} with + * JDK 16 and later (which will copy the request for modification in a builder). + * If that method is not available then use {@link Helpers#copy} (which also returns + * a builder). + * + * @param context context for the hook call + * @param request request to be transformed + * @return transformed request + * @throws Exception on error + */ + HttpRequest beforeRequest(BeforeRequestContext context, HttpRequest request) throws Exception; + + /** + * The default action is to return the request untouched. + */ + static BeforeRequest DEFAULT = (context, request) -> request; + } + + /** + * Specifies how a response is transformed before response processing. + */ + public interface AfterSuccess { + + /** + * Transforms the given response before response processing occurs. + * + * @param context context for the hook call + * @param response response to be transformed + * @return transformed response + * @throws Exception on error + */ + HttpResponse afterSuccess(AfterSuccessContext context, HttpResponse response) + throws Exception; + + /** + * The default action is to return the response untouched. + */ + static AfterSuccess DEFAULT = (context, response) -> response; + } + + /** + * Specifies what happens if a request action throws an Exception. + */ + public interface AfterError { + + /** + * Either returns an HttpResponse or throws an Exception. Must be passed either + * a response or an error (both can't be absent). + * + * @param context context for the error + * @param response response information if available. + * @param error the optional exception. If response present then the error is for-info + * only, it was the last error in the chain of AfterError hook + * calls leading to this one + * @return HTTP response if method decides that an exception is not to be thrown + * @throws Exception if error to be propagated + */ + HttpResponse afterError( + AfterErrorContext context, + Optional> response, + Optional error) throws Exception; + + /** + * The default action is to rethrow the given error. + */ + static AfterError DEFAULT = (context, response, error) -> { + Utils.checkArgument( + response.isPresent() ^ error.isPresent(), + "one and only one of response or error must be present"); + if (error.isPresent()) { + throw error.get(); + } else { + return response.get(); + } + }; + } + + public static final class SdkInitData { + private final String baseUrl; + private final HTTPClient client; + + public SdkInitData(String baseUrl, HTTPClient client) { + this.baseUrl = baseUrl; + this.client = client; + } + + public String baseUrl() { + return baseUrl; + } + + public HTTPClient client() { + return client; + } + } + + /** + * Transforms the HTTPClient before use. + */ + public interface SdkInit { + + /** + * Returns a transformed {@link HTTPClient} and {@code baseUrl} for use in requests. + * + * @param data data to transform + * @return the transformed data + */ + SdkInitData sdkInit(SdkInitData data); + + /** + * The default action is to return the client untouched. + */ + static SdkInit DEFAULT = data -> data; + + + } + + public static final class IdempotencyHook implements BeforeRequest { + + @Override + public HttpRequest beforeRequest(BeforeRequestContext context, HttpRequest request) throws Exception { + HttpRequest.Builder b = Helpers.copy(request); + b.header("Idempotency-Key", UUID.randomUUID().toString()); + return b.build(); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/HookAdapters.java b/src/main/java/com/google/genai/gaos/utils/HookAdapters.java new file mode 100644 index 00000000000..be2855a03e1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/HookAdapters.java @@ -0,0 +1,198 @@ +/* +* 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.utils; + +import java.io.InputStream; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +/** + * Utility class for adapting synchronous hooks to asynchronous hooks. + *

+ * This class provides adapter methods that convert synchronous hook implementations + * ({@link Hook.BeforeRequest}, {@link Hook.AfterSuccess}, {@link Hook.AfterError}) + * to their asynchronous counterparts ({@link AsyncHook.BeforeRequest}, + * {@link AsyncHook.AfterSuccess}, {@link AsyncHook.AfterError}). + *

+ * Performance Note: The execution of synchronous hooks is offloaded to the + * global {@link java.util.concurrent.ForkJoinPool#commonPool() ForkJoinPool}. + * For better performance in high-throughput scenarios, consider re-implementing + * hooks using non-blocking I/O (NIO) patterns instead of relying on these adapters. + *

+ * Thread Safety: All adapter methods are thread-safe and can be called + * concurrently from multiple threads. + * + * @see Hook + * @see AsyncHook + * @see java.util.concurrent.ForkJoinPool#commonPool() + */ +@SuppressWarnings("all") +public final class HookAdapters { + + private HookAdapters() { + // prevent instantiation + } + + /** + * Adapts a synchronous {@link Hook.BeforeRequest} to an asynchronous + * {@link AsyncHook.BeforeRequest}. + *

+ * The synchronous hook execution is offloaded to the global + * {@link java.util.concurrent.ForkJoinPool#commonPool() ForkJoinPool}. + * Any exceptions thrown by the synchronous hook are wrapped as unchecked + * exceptions and propagated through the returned {@link CompletableFuture}. + *

+ * Performance Consideration: For high-throughput applications, + * consider implementing the hook directly using NIO patterns rather than + * using this adapter, as it avoids thread pool overhead and blocking operations. + * + * @param beforeRequestHook the synchronous before-request hook to adapt + * @return an asynchronous before-request hook that executes the synchronous hook + * in the global ForkJoinPool + * @throws NullPointerException if {@code beforeRequestHook} is {@code null} + */ + public static AsyncHook.BeforeRequest toAsync(Hook.BeforeRequest beforeRequestHook) { + return ((context, request) -> CompletableFuture.supplyAsync( + () -> Exceptions.unchecked(() -> beforeRequestHook.beforeRequest(context, request)).get())); + } + + /** + * Adapts a synchronous {@link Hook.AfterError} to an asynchronous + * {@link AsyncHook.AfterError}. + *

+ * This method handles the conversion between different response body types: + *

    + *
  • Converts {@link HttpResponse}<{@link Blob}> to + * {@link HttpResponse}<{@link InputStream}> for the synchronous hook
  • + *
  • Converts the result back to {@link HttpResponse}<{@link Blob}> + * for the asynchronous interface
  • + *
+ *

+ * The synchronous hook execution is offloaded to the global + * {@link java.util.concurrent.ForkJoinPool#commonPool() ForkJoinPool}. + * Any exceptions thrown by the synchronous hook are wrapped as unchecked + * exceptions and propagated through the returned {@link CompletableFuture}. + *

+ * Performance Consideration: For high-throughput applications, + * consider implementing the hook directly using NIO patterns rather than + * using this adapter, as it avoids thread pool overhead and blocking I/O operations. + * + * @param afterErrorHook the synchronous after-error hook to adapt + * @return an asynchronous after-error hook that executes the synchronous hook + * in the global ForkJoinPool + * @throws NullPointerException if {@code afterErrorHook} is {@code null} + */ + public static AsyncHook.AfterError toAsync(Hook.AfterError afterErrorHook) { + return (context, response, error) -> toStreamResponse(response) + .thenCompose(backCompatResp -> { + CompletableFuture> processedResp = CompletableFuture.supplyAsync(() -> + Exceptions.unchecked(() -> + afterErrorHook.afterError( + context, + Optional.of(backCompatResp), + Optional.of(Exceptions.coerceException(error)))).get()); + + return processedResp + .thenApply(HookAdapters::toBlobResponse); + }); + + } + + /** + * Adapts a synchronous {@link Hook.AfterSuccess} to an asynchronous + * {@link AsyncHook.AfterSuccess}. + *

+ * This method handles the conversion between different response body types: + *

    + *
  • Converts {@link HttpResponse}<{@link Blob}> to + * {@link HttpResponse}<{@link InputStream}> for the synchronous hook
  • + *
  • Converts the result back to {@link HttpResponse}<{@link Blob}> + * for the asynchronous interface
  • + *
+ *

+ * The synchronous hook execution is offloaded to the global + * {@link java.util.concurrent.ForkJoinPool#commonPool() ForkJoinPool}. + * Any exceptions thrown by the synchronous hook are wrapped as unchecked + * exceptions and propagated through the returned {@link CompletableFuture}. + *

+ * Performance Consideration: For high-throughput applications, + * consider implementing the hook directly using NIO patterns rather than + * using this adapter, as it avoids thread pool overhead and blocking I/O operations. + * + * @param afterSuccessHook the synchronous after-success hook to adapt + * @return an asynchronous after-success hook that executes the synchronous hook + * in the global ForkJoinPool + * @throws NullPointerException if {@code afterSuccessHook} is {@code null} + */ + public static AsyncHook.AfterSuccess toAsync(Hook.AfterSuccess afterSuccessHook) { + return (context, response) -> toStreamResponse(response) + .thenCompose(backCompatResp -> { + CompletableFuture> processedResp = CompletableFuture.supplyAsync(() -> + Exceptions.unchecked(() -> + afterSuccessHook.afterSuccess( + context, + backCompatResp)).get()); + + return processedResp + .thenApply(HookAdapters::toBlobResponse); + }); + + } + + /** + * Converts an {@link HttpResponse}<{@link InputStream}> to an + * {@link HttpResponse}<{@link Blob}>. + *

+ * This method wraps the InputStream response body in a {@link Blob} while + * preserving all other response metadata (status code, headers, etc.). + *

+ * Note: The resulting {@link Blob} is created from the InputStream, + * which means it may not support retries effectively if the InputStream + * gets consumed during the first attempt. + * + * @param response the response with InputStream body to convert + * @return a new response with the same metadata but with a Blob body + * @throws NullPointerException if {@code response} is {@code null} + */ + private static HttpResponse toBlobResponse(HttpResponse response) { + return new ResponseWithBody<>(response, Blob.from(response.body())); + } + + /** + * Converts an {@link HttpResponse}<{@link Blob}> to an + * {@link HttpResponse}<{@link InputStream}>. + *

+ * This method asynchronously converts the Blob response body to an InputStream + * while preserving all other response metadata (status code, headers, etc.). + * The conversion is performed using {@link Blob#toInputStream()}. + *

+ * Note: This operation consumes the {@link Blob}, making it unavailable + * for further use after this conversion. + * + * @param response the response with Blob body to convert + * @return a CompletableFuture containing a new response with the same metadata + * but with an InputStream body + * @throws NullPointerException if {@code response} is {@code null} + */ + private static CompletableFuture> toStreamResponse(HttpResponse response) { + return response.body().toInputStream().thenApply(body -> new ResponseWithBody<>(response, body)); + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/Hooks.java b/src/main/java/com/google/genai/gaos/utils/Hooks.java new file mode 100644 index 00000000000..6f920e8f2f3 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Hooks.java @@ -0,0 +1,232 @@ +/* +* 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.utils; + +import java.io.InputStream; +import java.net.http.HttpResponse; +import java.net.http.HttpRequest; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CopyOnWriteArrayList; + +import com.google.genai.gaos.utils.Hook.AfterError; +import com.google.genai.gaos.utils.Hook.AfterErrorContext; +import com.google.genai.gaos.utils.Hook.AfterSuccess; +import com.google.genai.gaos.utils.Hook.AfterSuccessContext; +import com.google.genai.gaos.utils.Hook.BeforeRequest; +import com.google.genai.gaos.utils.Hook.BeforeRequestContext; +import com.google.genai.gaos.utils.Hook.SdkInit; +import com.google.genai.gaos.utils.Hook.SdkInitData; + +/** + * Registers hooks for use at runtime by an end-user or for use by a customer + * that may edit the SDKHooks.java file. + * + *

+ * For example, this code will add a transaction id header to every request: + * + *

+ * hooks.registerBeforeRequest((context, request) -> {
+ *     request.headers().map().put("acme-transaction-id", nextTransactionId());
+ *     return request;
+ * });
+ * 
+ */ +// ThreadSafe +@SuppressWarnings("all") +public class Hooks implements BeforeRequest, AfterSuccess, AfterError, SdkInit { + + private static final SpeakeasyLogger logger = SpeakeasyLogger.getLogger(Hooks.class); + + // we use CopyOnWriteArrayList for thread safety + private final List beforeRequestHooks = new CopyOnWriteArrayList<>(); + private final List afterSuccessHooks = new CopyOnWriteArrayList<>(); + private final List afterErrorHooks = new CopyOnWriteArrayList<>(); + private final List SdkInitHooks = new CopyOnWriteArrayList<>(); + + /** + * Constructor. + */ + public Hooks() { + } + + /** + * Registers a {@link BeforeRequest} hook to be applied in order of + * registration. The result of the first BeforeRequest hook will be passed to + * the second BeforeRequest hook and processed similarly for the rest of the + * registered hooks. If a BeforeRequest hook throws then that Exception will + * not be passed to the {@link AfterError} hooks. + * + * @param beforeRequest hook to be registered + * @return this + */ + public Hooks registerBeforeRequest(BeforeRequest beforeRequest) { + Utils.checkNotNull(beforeRequest, "beforeRequest"); + this.beforeRequestHooks.add(beforeRequest); + logger.debug("Registered BeforeRequest hook: {} (total: {})", beforeRequest.getClass().getSimpleName(), beforeRequestHooks.size()); + return this; + } + + /** + * Registers an {@link AfterSuccess} hook to be applied in order of registration + * (multiple can be registered). The result of the first AfterSuccess hook will + * be passed to the second AfterSuccess hook and processed similarly for the + * rest of the registered hooks. If an AfterSuccess hook throws then that + * Exception will not be passed to the {@link AfterError} hooks. + * + * @param afterSuccess hook to be registered + * @return this + */ + public Hooks registerAfterSuccess(AfterSuccess afterSuccess) { + Utils.checkNotNull(afterSuccess, "afterSuccess"); + this.afterSuccessHooks.add(afterSuccess); + logger.debug("Registered AfterSuccess hook: {} (total: {})", afterSuccess.getClass().getSimpleName(), afterSuccessHooks.size()); + return this; + } + + /** + * Registers an {@link AfterError} hook to be applied in order of registration + * (multiple can be registered). If the first AfterError hook throws then the + * second hook will be called with that exception (and no response object) and + * so on for the rest of the registered hooks. If an AfterError hook returns + * normally then its result will be passed through to the next AfterError hook + * with the latest thrown Exception. + * + * @param afterError hook to be registered + * @return this + */ + public Hooks registerAfterError(AfterError afterError) { + Utils.checkNotNull(afterError, "afterError"); + this.afterErrorHooks.add(afterError); + logger.debug("Registered AfterError hook: {} (total: {})", afterError.getClass().getSimpleName(), afterErrorHooks.size()); + return this; + } + + /** + * Registers a {@link SdkInit} hook to be applied in order of registration + * (multiple can be registered). + * + * @param SdkInit hook to be registered + * @return this + */ + public Hooks registerSdkInit(SdkInit SdkInit) { + Utils.checkNotNull(SdkInit, "SdkInit"); + this.SdkInitHooks.add(SdkInit); + logger.debug("Registered SdkInit hook: {} (total: {})", SdkInit.getClass().getSimpleName(), SdkInitHooks.size()); + return this; + } + + @Override + public HttpRequest beforeRequest(BeforeRequestContext context, HttpRequest request) throws Exception { + Utils.checkNotNull(context, "context"); + Utils.checkNotNull(request, "request"); + if (logger.isTraceEnabled() && !beforeRequestHooks.isEmpty()) { + logger.trace("Executing {} beforeRequest hook(s) for operation: {}", beforeRequestHooks.size(), context.operationId()); + } + for (BeforeRequest hook : beforeRequestHooks) { + request = hook.beforeRequest(context, request); + } + return request; + } + + @Override + public HttpResponse afterSuccess(AfterSuccessContext context, HttpResponse response) + throws Exception { + Utils.checkNotNull(context, "context"); + Utils.checkNotNull(response, "response"); + + if (logger.isTraceEnabled() && !afterSuccessHooks.isEmpty()) { + logger.trace("Executing {} afterSuccess hook(s) for operation: {}", afterSuccessHooks.size(), context.operationId()); + } + for (AfterSuccess hook : afterSuccessHooks) { + response = hook.afterSuccess(context, response); + if (response == null) { + throw new IllegalStateException("afterSuccess cannot return null"); + } + } + return response; + } + + @Override + public HttpResponse afterError( + AfterErrorContext context, + Optional> response, + Optional error) throws Exception { + Utils.checkNotNull(context, "context"); + Utils.checkNotNull(response, "response"); + Utils.checkNotNull(error, "error"); + Utils.checkArgument( + response.isPresent() ^ error.isPresent(), + "one and only one of response or error must be present"); + + if (logger.isTraceEnabled() && !afterErrorHooks.isEmpty()) { + logger.trace("Executing {} afterError hook(s) for operation: {}", afterErrorHooks.size(), context.operationId()); + } + for (AfterError hook : afterErrorHooks) { + try { + response = Optional.ofNullable(hook.afterError(context, response, error)); + if (!response.isPresent()) { + throw new IllegalStateException( + "afterError must either throw an exception or return a non-null response"); + } + } catch (FailEarlyException e) { + Throwable cause = e.getCause(); + if (cause instanceof Exception) { + throw (Exception) cause; + } else { + // must be an Error + throw (Error) cause; + } + } catch (Exception e) { + logger.debug("Hook threw exception: {}", e.getClass().getSimpleName()); + error = Optional.of(e); + response = Optional.empty(); + } + } + if (response.isPresent()) { + return response.get(); + } else { + throw error.get(); + } + } + + @Override + public SdkInitData sdkInit(SdkInitData data) { + Utils.checkNotNull(data, "data"); + if (logger.isDebugEnabled() && !SdkInitHooks.isEmpty()) { + logger.debug("Executing {} sdkInit hook(s)", SdkInitHooks.size()); + } + for (SdkInit hook : SdkInitHooks) { + data = hook.sdkInit(data); + if (data == null) { + throw new IllegalStateException("sdkInit cannot return null"); + } + } + return data; + } + + @SuppressWarnings("serial") + public static final class FailEarlyException extends RuntimeException { + public FailEarlyException(Exception e) { + super(e); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/JSON.java b/src/main/java/com/google/genai/gaos/utils/JSON.java new file mode 100644 index 00000000000..3b30047cfb3 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/JSON.java @@ -0,0 +1,47 @@ +/* +* 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.utils; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; + + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.databind.ObjectMapper; + +@SuppressWarnings("all") +public class JSON { + private static final ObjectMapper MAPPER = new ObjectMapper() + .registerModule(new JavaTimeModule()) + .registerModule(new Jdk8Module()) + + .registerModule(Deserializers.STRICT_DESERIALIZERS) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) + .setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); + public static ObjectMapper getMapper() { + return MAPPER; + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/LazySingletonValue.java b/src/main/java/com/google/genai/gaos/utils/LazySingletonValue.java new file mode 100644 index 00000000000..421646ffce7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/LazySingletonValue.java @@ -0,0 +1,47 @@ +/* +* 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.utils; + +import com.fasterxml.jackson.core.type.TypeReference; + +@SuppressWarnings("all") +public final class LazySingletonValue { + + private static final Object NOT_SET = new Object(); + + private final String name; + private final String json; + private final TypeReference typeReference; + private Object value = NOT_SET; + + public LazySingletonValue(String name, String json, TypeReference typeReference) { + this.name = name; + this.json = json; + this.typeReference = typeReference; + } + + @SuppressWarnings("unchecked") + public T value() { + if (value == NOT_SET) { + value = Utils.readDefaultOrConstValue(name, json, typeReference); + } + return (T) value; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Metadata.java b/src/main/java/com/google/genai/gaos/utils/Metadata.java new file mode 100644 index 00000000000..550fe5574bd --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Metadata.java @@ -0,0 +1,99 @@ +/* +* 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.utils; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; + +@SuppressWarnings("all") +final class Metadata { + + private Metadata() { + // prevent instantiation + } + + static T parse(String name, T metadata, Field field) + throws IllegalArgumentException, IllegalAccessException { + SpeakeasyMetadata md = field.getAnnotation(SpeakeasyMetadata.class); + if (md == null) { + return null; + } + + String mdValue = md.value(); + + if (mdValue == null || mdValue.isBlank()) { + return null; + } + + String[] groups = mdValue.split(" "); + + boolean handled = false; + + for (String group : groups) { + String[] parts = group.split(":"); + if (parts.length != 2) { + return null; + } + + if (!parts[0].equals(name)) { + continue; + } + + Map values = new HashMap<>(); + + String[] pairs = parts[1].split(","); + for (String pair : pairs) { + String[] keyVal = pair.split("="); + String key = keyVal[0]; + + String val = ""; + if (keyVal.length > 1) { + val = keyVal[1]; + } + + values.put(key, val); + } + + Field[] fields = metadata.getClass().getDeclaredFields(); + + for (Field f : fields) { + f.setAccessible(true); + if (values.containsKey(f.getName())) { + String val = values.get(f.getName()); + + if (f.getType().equals(boolean.class) || f.getType().equals(Boolean.class)) { + f.set(metadata, val.equals("true") || val.isBlank()); + } else { + f.set(metadata, val); + } + } + } + + handled = true; + } + + if (!handled) { + return null; + } + + return (T) metadata; + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/Multipart.java b/src/main/java/com/google/genai/gaos/utils/Multipart.java new file mode 100644 index 00000000000..6285937d82a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Multipart.java @@ -0,0 +1,242 @@ +/* +* 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.utils; + +import com.google.genai.gaos.utils.reactive.ReactiveUtils; + +import java.net.URLEncoder; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.Flow; + +@SuppressWarnings("all") +public final class Multipart { + + private static final String CRLF = "\r\n"; + private static final String DASHES = "--"; + private static final Charset HDR_CS = StandardCharsets.ISO_8859_1; // headers + private static final Charset TXT_CS = StandardCharsets.UTF_8; // text fields + private static final String DEFAULT_FILE_CT = "application/octet-stream"; + public static final String DEFAULT_TEXT_CT = "text/plain; charset=UTF-8"; + + private final BodyPublisher bodyPublisher; + private final String boundary; + + private Multipart(BodyPublisher bodyPublisher, String boundary) { + this.bodyPublisher = bodyPublisher; + this.boundary = boundary; + } + + public BodyPublisher bodyPublisher() { + return bodyPublisher; + } + + /** + * Visible for tests. + */ + public String boundary() { + return boundary; + } + + /** + * RFC 7578: no charset parameter at the multipart level. + */ + public String contentType() { + return "multipart/form-data; boundary=" + boundary; + } + + public static Builder builder() { + return new Builder(); + } + + // ------------------------------------------------------- + // Builder + // ------------------------------------------------------- + public static final class Builder { + private final List parts = new ArrayList<>(); + private final String boundary = UUID.randomUUID().toString(); + + public Builder addPart(String name, String value) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(value, "value"); + parts.add(new FormField(name, value, DEFAULT_TEXT_CT)); + return this; + } + + public Builder addPart(String name, String value, String contentType) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(value, "value"); + Utils.checkNotNull(contentType, "contentType"); + parts.add(new FormField(name, value, contentType)); + return this; + } + + public Builder addPart(String name, byte[] bytes, String filename, String contentType) { + return addPart(name, Blob.from(bytes), filename, contentType); + } + + public Builder addPart(String name, Blob blob, String filename, String contentType) { + Utils.checkNotNull(name, "name"); + Utils.checkNotNull(blob, "blob"); + Utils.checkNotNull(filename, "filename"); + parts.add(new FilePart(name, blob, filename, + Optional.ofNullable(contentType).orElse(DEFAULT_FILE_CT))); + return this; + } + + public Multipart build() { + if (parts.isEmpty()) { + throw new IllegalStateException("Must have at least one part to build multipart message."); + } + + // Build publishers for each part plus the closing boundary. + List pubs = new ArrayList<>(parts.size() + 1); + for (Part p : parts) { + pubs.add(p.toPublisher(boundary)); + } + pubs.add(BodyPublishers.ofString(DASHES + boundary + DASHES + CRLF, HDR_CS)); + + BodyPublisher multipart = concat(pubs); + return new Multipart(multipart, boundary); + } + } + + // ------------------------------------------------------- + // Part model + // ------------------------------------------------------- + interface Part { + BodyPublisher toPublisher(String boundary); + } + + /** + * Text form field. + */ + static final class FormField implements Part { + private final String name; + private final String value; + private final String contentType; + + FormField(String name, String value, String contentType) { + this.name = name; + this.value = value; + this.contentType = contentType != null ? contentType : "text/plain; charset=UTF-8"; + } + + @Override + public BodyPublisher toPublisher(String boundary) { + String header = DASHES + boundary + CRLF + + "Content-Disposition: form-data; name=\"" + escapeQuoted(name) + "\"" + CRLF + + "Content-Type: " + contentType + CRLF + + CRLF; + + BodyPublisher h = BodyPublishers.ofString(header, HDR_CS); + BodyPublisher b = BodyPublishers.ofString(value, TXT_CS); + BodyPublisher t = BodyPublishers.ofString(CRLF, HDR_CS); + + return concat(h, b, t); + } + } + + /** + * File / blob upload. + */ + static final class FilePart implements Part { + private final String name; + private final String filename; + private final String contentType; + private final Blob blob; + + FilePart(String name, Blob blob, String filename, String contentType) { + this.name = name; + this.filename = filename; + this.contentType = contentType != null ? contentType : DEFAULT_FILE_CT; + this.blob = blob; + } + + @Override + public BodyPublisher toPublisher(String boundary) { + String cd = contentDispositionWithFilename(name, filename); + String header = DASHES + boundary + CRLF + + "Content-Disposition: " + cd + CRLF + + "Content-Type: " + contentType + CRLF + + CRLF; + + BodyPublisher h = BodyPublishers.ofString(header, HDR_CS); + BodyPublisher c = BodyPublishers.fromPublisher(blob.asPublisher()); // streaming + BodyPublisher t = BodyPublishers.ofString(CRLF, HDR_CS); + + return concat(h, c, t); + } + } + + // ------------------------------------------------------- + // Helpers + // ------------------------------------------------------- + private static String escapeQuoted(String s) { + Objects.requireNonNull(s, "quoted string"); + StringBuilder out = new StringBuilder(s.length()); + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (c == '"' || c == '\\') out.append('\\').append(c); + else if (c == '\r' || c == '\n') out.append(' '); + else out.append(c); + } + return out.toString(); + } + + /** + * RFC 5987 filename* with ASCII fallback. + */ + private static String contentDispositionWithFilename(String name, String filename) { + String safeName = escapeQuoted(name); + String fallback = escapeQuoted(asAsciiFilenameFallback(filename)); + String encoded; + try { + encoded = URLEncoder.encode(filename, TXT_CS).replace("+", "%20"); + } catch (Exception e) { + encoded = fallback; + } + return "form-data; name=\"" + safeName + "\"; filename=\"" + fallback + "\"; filename*=UTF-8''" + encoded; + } + + private static String asAsciiFilenameFallback(String filename) { + StringBuilder sb = new StringBuilder(filename.length()); + for (int i = 0; i < filename.length(); i++) { + char c = filename.charAt(i); + if (c >= 0x20 && c <= 0x7E && c != '"' && c != '\\') sb.append(c); + else sb.append('_'); + } + return sb.toString(); + } + + private static BodyPublisher concat(BodyPublisher... publishers) { + return BodyPublishers.fromPublisher(ReactiveUtils.concat(List.of(publishers))); + } + + private static BodyPublisher concat(List publishers) { + List> bufferPublishers = List.copyOf(publishers); + return BodyPublishers.fromPublisher(ReactiveUtils.concat(bufferPublishers)); + } + +} diff --git a/src/main/java/com/google/genai/gaos/utils/MultipartFormMetadata.java b/src/main/java/com/google/genai/gaos/utils/MultipartFormMetadata.java new file mode 100644 index 00000000000..700c65e68fc --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/MultipartFormMetadata.java @@ -0,0 +1,39 @@ +/* +* 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.utils; + +import java.lang.reflect.Field; + +@SuppressWarnings("all") +class MultipartFormMetadata { + + boolean file; + boolean content; + boolean json; + String name; + + private MultipartFormMetadata() { + } + + // multipartForm:name=file + static MultipartFormMetadata parse(Field field) throws IllegalArgumentException, IllegalAccessException { + return Metadata.parse("multipartForm", new MultipartFormMetadata(), field); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/NameValue.java b/src/main/java/com/google/genai/gaos/utils/NameValue.java new file mode 100644 index 00000000000..10eec14154c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/NameValue.java @@ -0,0 +1,39 @@ +/* +* 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.utils; + +@SuppressWarnings("all") +final class NameValue { + private final String name; + private final String value; + + NameValue(String name, String value) { + this.name = name; + this.value = value; + } + + String name() { + return name; + } + + String value() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/NonRetryableException.java b/src/main/java/com/google/genai/gaos/utils/NonRetryableException.java new file mode 100644 index 00000000000..f2f95a1a727 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/NonRetryableException.java @@ -0,0 +1,34 @@ +/* +* 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.utils; + +@SuppressWarnings("all") +public final class NonRetryableException extends Exception { + private final Throwable throwable; + + public NonRetryableException(Throwable throwable) { + super(throwable); + this.throwable = throwable; + } + + public Throwable exception() { + return throwable; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/OneOfDeserializer.java b/src/main/java/com/google/genai/gaos/utils/OneOfDeserializer.java new file mode 100644 index 00000000000..e888d8ad5f0 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/OneOfDeserializer.java @@ -0,0 +1,548 @@ +/* +* 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.utils; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import com.google.genai.gaos.utils.Utils.TypeReferenceWithShape; + + + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DatabindException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + + +@SuppressWarnings("all") +public class OneOfDeserializer extends StdDeserializer { + + private static final long serialVersionUID = -1; + + private final transient List typeReferences; // oneOf subschemas + private final Class cls; + private final ObjectMapper mapper; + + /** + * Constructor. + * + * @param cls oneOf type + * @param strict deprecated parameter, no longer used (kept for backward compatibility) + * @param typeReferences the types of the oneOf subschemas + */ + protected OneOfDeserializer(Class cls, boolean strict, TypeReferenceWithShape... typeReferences) { + super(cls); + this.typeReferences = Arrays.asList(typeReferences); + this.cls = cls; + this.mapper = JSON.getMapper(); + } + + @Override + public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + TreeNode tree = p.getCodec().readTree(p); + return deserializeOneOf(mapper, tree, typeReferences, cls); + } + + private static T deserializeOneOf(ObjectMapper mapper, TreeNode tree, + List typeReferences, Class cls) throws JsonProcessingException { + // TODO don't have to generate json because can use tree.traverse to get a + // parser to read value, perf advantage and can stop plugging in ObjectMapper + String json = mapper.writeValueAsString(tree); + List> matches = new ArrayList<>(); + for (TypeReferenceWithShape c : typeReferences) { + // try to deserialize with each of the member classes + // @formatter:off + try { + JavaType jt = Utils.convertToShape(mapper.getTypeFactory(), c.typeReference(), c.shape()); + // Jackson very permissive with readValue so we will tighten things up a bit + if (matchPossible(jt, json)) { + Object o = mapper.readValue(json, jt); + o = Utils.convertToShapeInverse(o, c.shape(), jt); + @SuppressWarnings("unchecked") + TypedObject typed = TypedObject.of(o, c.shape(), (TypeReference) c.typeReference()); + T v = newInstance(cls, typed); + matches.add(new Match<>(c, v, tree)); + } + } catch (DatabindException ignored) {} // NOPMD + // @formatter:on + } + // Short-circuit if single match + if (matches.size() == 1) { + return matches.get(0).value; + } + + matches = applyMatchPreferences(matches, json); + + if (!matches.isEmpty()) { + return matches.get(0).value; + } + + // No types matched - fall back to JsonNode + // TreeNode is already parsed, just cast to JsonNode + JsonNode node; + if (tree instanceof JsonNode) { + node = (JsonNode) tree; + } else { + // Shouldn't happen with Jackson's default implementation, but handle gracefully + node = mapper.readTree(json); + } + + // Wrap JsonNode in TypedObject and create union instance + TypedObject typed = TypedObject.of(node, Utils.JsonShape.DEFAULT, + new TypeReference() {}); + return newInstance(cls, typed); + } + /** + * Represents a candidate deserialization result for oneOf schema matching. + * Candidates are compared using a multi-level tie-breaking strategy to determine + * the best match when multiple schemas successfully deserialize the input. + */ + private static final class Match implements Comparable> { + final TypeReferenceWithShape typeReference; + final T value; + private final TreeNode tree; + private int matched = 0; // Count of matched fields (includes inexact) + private int inexact = 0; // Count of fields with unknown/unrecognized enum values + private int unmatched = 0; // Count of struct fields not found in raw JSON + + Match(TypeReferenceWithShape typeReference, T value, TreeNode tree) { + this.typeReference = typeReference; + this.value = value; + this.tree = tree; + } + + /** + * Populates the matched, inexact, and unmatched field counts by recursively + * analyzing the deserialized value against the JSON structure. + */ + private void countFields() { + try { + Object unwrapped = unwrapValue(value); + JsonNode jsonNode = tree instanceof JsonNode ? (JsonNode) tree : null; + if (jsonNode != null) { + countFieldsRecursive(unwrapped, jsonNode); + } + } catch (Exception e) { + // Keep counts at 0 on error + } + } + + /** + * Recursively counts matched, inexact, and unmatched fields by walking the object + * graph based on JSON structure. + * + * @param obj the deserialized object to traverse + * @param jsonNode the corresponding JSON node + */ + private void countFieldsRecursive(Object obj, JsonNode jsonNode) { + // Unwrap union wrappers to get the active variant value + obj = unwrapValue(obj); + + // Handle null JSON value + if (jsonNode != null && jsonNode.isNull()) { + // Null JSON value matches null object or JsonNullable containing null + matched++; + return; + } + + if (obj == null || jsonNode == null) { + return; + } + + + // Unwrap optional fields + if (obj instanceof java.util.Optional) { + java.util.Optional opt = (java.util.Optional) obj; + if (opt.isPresent()) { + countFieldsRecursive(opt.get(), jsonNode); + } + return; + } + + // Handle primitives and strings + if (isPrimitiveOrString(obj)) { + matched++; + return; + } + + // Handle standard Java enums and enum wrappers + if (obj.getClass().isEnum() || Reflections.isEnumWrapper(obj)) { + matched++; + try { + // Check if it's an unknown enum value (only for enum wrappers) + if (Reflections.isEnumWrapper(obj)) { + java.lang.reflect.Method isKnownMethod = obj.getClass().getMethod("isKnown"); + Boolean isKnown = (Boolean) isKnownMethod.invoke(obj); + if (isKnown != null && !isKnown) { + inexact++; + return; + } + } + } catch (Exception e) { + // If value() method doesn't exist or fails, treat as exact + } + return; + } + + try { + // Recurse through collections + if (obj instanceof Collection && jsonNode.isArray()) { + int index = 0; + for (Object element : (Collection) obj) { + if (element != null && index < jsonNode.size()) { + JsonNode elementNode = jsonNode.get(index); + countFieldsRecursive(element, elementNode); + } + index++; + } + return; + } + + // Recurse through maps + if (obj instanceof Map && jsonNode.isObject()) { + for (Map.Entry entry : ((Map) obj).entrySet()) { + if (entry.getKey() != null && entry.getValue() != null) { + String key = entry.getKey().toString(); + if (jsonNode.has(key)) { + JsonNode valueNode = jsonNode.get(key); + countFieldsRecursive(entry.getValue(), valueNode); + } + } + } + return; + } + + // Recurse through object fields + if (jsonNode.isObject() && !(obj instanceof Map)) { + for (Field field : obj.getClass().getDeclaredFields()) { + if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) continue; + + field.setAccessible(true); + Object fieldValue = field.get(obj); + String fieldName = getJsonFieldName(field); + + if (fieldName == null) { + continue; // Skip fields marked with @JsonIgnore or json:"-" + } + + if (!jsonNode.has(fieldName)) { + // Field exists in struct but not in JSON + unmatched++; + continue; + } + + // Recurse into field regardless of whether it's null + // (null fields with null JSON values should be counted as matched) + JsonNode fieldNode = jsonNode.get(fieldName); + countFieldsRecursive(fieldValue, fieldNode); + } + } + } catch (Exception e) { + // Ignore errors during recursion + } + } + + /** + * Gets the JSON field name for a Java field, respecting @JsonProperty annotations. + * Returns null if the field should be skipped (e.g., @JsonIgnore or no Jackson annotations). + */ + private String getJsonFieldName(Field field) { + // Check for @JsonIgnore + if (field.isAnnotationPresent(com.fasterxml.jackson.annotation.JsonIgnore.class)) { + return null; + } + + // Check for @JsonProperty - only include fields with Jackson annotations + if (field.isAnnotationPresent(com.fasterxml.jackson.annotation.JsonProperty.class)) { + com.fasterxml.jackson.annotation.JsonProperty prop = + field.getAnnotation(com.fasterxml.jackson.annotation.JsonProperty.class); + String value = prop.value(); + if (value != null && !value.isEmpty()) { + return value; + } + // If @JsonProperty is present but value is empty, use field name + return field.getName(); + } + + // Skip fields without Jackson annotations + return null; + } + + /** + * Compares candidates using a multi-level tie-breaking strategy: + *
+         * 1. Matched count (higher is better)
+         * 2. Inexact count (lower is better)
+         * 3. Unmatched count (lower is better - fewer zero defaulted values)
+         * 
+ */ + @Override + public int compareTo(Match other) { + // Primary: number of matched fields (higher is better) + int matchedComparison = Integer.compare(this.matched, other.matched); + if (matchedComparison != 0) { + return matchedComparison; + } + + // Secondary: number of inexact fields (lower is better, prefer exactness) + int inexactComparison = Integer.compare(other.inexact, this.inexact); + if (inexactComparison != 0) { + return inexactComparison; + } + + // Tertiary: unmatched count (lower is better) + return Integer.compare(other.unmatched, this.unmatched); + } + } + + /** + * Unwraps union wrappers to extract the active variant value. + * Union wrappers contain a TypedObject field annotated with @JsonValue. + * This ensures field counting only considers the active variant, not all union members. + * + * @param wrapper the union wrapper instance + * @return the actual deserialized value, or wrapper unchanged if not a union + */ + private static Object unwrapValue(Object wrapper) { + if (wrapper == null) { + return null; + } + + // Extract the @JsonValue field from wrapper union classes + // Wrapper classes have a TypedObject field annotated with @JsonValue + try { + for (Field field : wrapper.getClass().getDeclaredFields()) { + if (field.isAnnotationPresent(com.fasterxml.jackson.annotation.JsonValue.class)) { + field.setAccessible(true); + Object fieldValue = field.get(wrapper); + // Unwrap the TypedObject to get the actual value + if (fieldValue instanceof TypedObject) { + return ((TypedObject) fieldValue).value(); + } + return fieldValue; + } + } + } catch (Exception e) { + // Fall through to return as-is + } + + return wrapper; + } + + + + + + private static boolean isPrimitiveOrString(Object obj) { + Class clazz = obj.getClass(); + return clazz.isPrimitive() || + clazz == String.class || + clazz == Integer.class || + clazz == Long.class || + clazz == Double.class || + clazz == Float.class || + clazz == Boolean.class || + clazz == BigDecimal.class || + clazz == BigInteger.class || + clazz == OffsetDateTime.class || + clazz == LocalDate.class; + } + + private static final Set NUMERIC_CLASSES = Set.of( + Integer.class.getCanonicalName(), + Long.class.getCanonicalName(), + BigInteger.class.getCanonicalName(), + Float.class.getCanonicalName(), + Double.class.getCanonicalName(), + BigDecimal.class.getCanonicalName()); + + private static final Set DECIMAL_CLASSES = Set.of( + Float.class.getCanonicalName(), + Double.class.getCanonicalName(), + BigDecimal.class.getCanonicalName()); + + private static final Set INTEGER_CLASSES = Set.of( + Integer.class.getCanonicalName(), + Long.class.getCanonicalName(), + BigInteger.class.getCanonicalName()); + + private static final Set DATE_TIME_CLASSES = Set.of( + OffsetDateTime.class.getCanonicalName(), + LocalDate.class.getCanonicalName()); + + // VisibleForTesting + public static boolean matchPossible(JavaType type, String json) { + // situations we want to AVOID that can happen with Jackson ObjectMapper: + // * json numeric considered as valid for deserialization to OffsetDateTime, LocalDate + // * non-double-quoted json string considered as valid string + // * json numeric can be parsed as a Boolean + // * double-quoted numerics can be parsed as numerics + + // We make important assumptions about matching json with types + if (typeIs(type, String.class) || typeIs(type, BigIntegerString.class) || typeIs(type, BigDecimalString.class)) { + // string must be double quoted + return isDoubleQuoted(json); + } else if (typeIs(type, Boolean.class)) { + // boolean can only have false or true values + return json.equals("true") || json.equals("false"); + } else if (NUMERIC_CLASSES.contains(type.getTypeName())) { + return !json.contains("\""); + } else if (typeIs(type, OffsetDateTime.class) || typeIs(type, LocalDate.class)) { + // only json schema datetime format accepted, not epoch ms/s etc. + return isDoubleQuoted(json) && !isNumeric(json.substring(1, json.length() - 1)); + } else { + return true; + } + } + + private static boolean isDoubleQuoted(String s) { + return s.length() >= 2 && s.startsWith("\"") && s.endsWith("\""); + } + /** + * Applies candidate preference rules to resolve multiple matches. + * Uses legacy type-specific preferences for backward compatibility, then applies + * smart scoring using field mapping analysis for enhanced resolution. + */ + // VisibleForTesting + public static List> applyMatchPreferences(List> matches, String json) { + if (matches.size() <= 1) { + return matches; + } + + // Apply legacy type-specific preferences for backward compatibility + if (allNumeric(matches)) { + List> decimalMatches = decimalMatches(matches); + List> integerMatches = integerMatches(matches); + if (!decimalMatches.isEmpty() && !integerMatches.isEmpty()) { + matches = json.contains("e") || json.contains(".") ? decimalMatches : integerMatches; + } else if (!decimalMatches.isEmpty()) { + matches = decimalMatches; + } else { + matches = integerMatches; + } + } else if (allDateTime(matches)) { + matches = json.contains("T") ? filter(matches, OffsetDateTime.class) : filter(matches, LocalDate.class); + } + + // Apply smart scoring using natural ordering if still multiple candidates + if (matches.size() > 1) { + // Count fields for each match before sorting + for (Match match : matches) { + match.countFields(); + } + + return matches.stream() + .sorted(Comparator.reverseOrder()) // Best candidates first (highest scores) + .collect(Collectors.toList()); + } + + return matches; + } + + private static List> filter(List> matches, Class filterByClass) { + return matches // + .stream() // + .filter(x -> x.typeReference.typeReference().getType().getTypeName().equals(filterByClass.getCanonicalName())) // + .collect(Collectors.toList()); + } + + private static boolean allDateTime(List> matches) { + return matches.stream().allMatch(x -> DATE_TIME_CLASSES.contains(x.typeReference.typeReference().getType().getTypeName())); + } + + private static boolean allNumeric(List> matches) { + return matches.stream().allMatch(x -> NUMERIC_CLASSES.contains(x.typeReference.typeReference().getType().getTypeName())); + } + + private static List> decimalMatches(List> matches) { + return matches // + .stream() // + .filter(x -> DECIMAL_CLASSES.contains(x.typeReference.typeReference().getType().getTypeName())) // + .collect(Collectors.toList()); + } + + private static List> integerMatches(List> matches) { + return matches // + .stream() // + .filter(x -> INTEGER_CLASSES.contains(x.typeReference.typeReference().getType().getTypeName())) // + .collect(Collectors.toList()); + } + + private static boolean isNumeric(String s) { + try { + Double.parseDouble(s); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + private static boolean typeIs(JavaType type, Class cls) { + return type.getRawClass().equals(cls); + } + + private static String typeNames(List> matches) { + return "[" + matches + .stream() + .map(x -> x.typeReference.typeReference().getType().getTypeName()) + .collect(Collectors.joining(", ")) + "]"; + } + + private static String typeReferenceNames(List list) { + return "[" + list + .stream() + .map(x -> x.typeReference().getType().getTypeName()) + .collect(Collectors.joining(", ")) + "]"; + } + + private static T newInstance(Class cls, Object parameter) { + try { + Constructor con = cls.getDeclaredConstructor(TypedObject.class); + con.setAccessible(true); + return con.newInstance(parameter); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | SecurityException e) { + throw new RuntimeException(e); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/OpenapiJacksonModule.java b/src/main/java/com/google/genai/gaos/utils/OpenapiJacksonModule.java new file mode 100644 index 00000000000..02c8d95641d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/OpenapiJacksonModule.java @@ -0,0 +1,82 @@ +/* +* 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.utils; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +/** + * A composite Jackson {@link Module} that registers all SDK-required Jackson customizations. + * + *

Register this with a custom {@link ObjectMapper} to enable full serialization support + * for SDK types. Bundles {@code JavaTimeModule}, {@code Jdk8Module}, + * and SDK strict deserializers, and applies the same feature flags used by + * {@link JSON#getMapper()}: + *

    + *
  • Disables {@code WRITE_DATES_AS_TIMESTAMPS} (ISO-8601 date strings)
  • + *
  • Disables {@code FAIL_ON_UNKNOWN_PROPERTIES}
  • + *
  • Disables {@code FAIL_ON_EMPTY_BEANS}
  • + *
  • Enables {@code FAIL_ON_NULL_FOR_PRIMITIVES}
  • + *
  • Restricts field visibility to annotated fields only
  • + *
+ * + *
{@code
+ * ObjectMapper myMapper = new ObjectMapper()
+ *     .registerModule(new OpenapiJacksonModule());
+ * String json = myMapper.writeValueAsString(response);
+ * }
+ * + *

Alternatively, use {@link JSON#getMapper()} to access the pre-configured SDK mapper directly. + */ +@SuppressWarnings("all") +public class OpenapiJacksonModule extends Module { + + @Override + public String getModuleName() { + return "OpenapiJacksonModule"; + } + + @Override + public Version version() { + return Version.unknownVersion(); + } + + @Override + public void setupModule(SetupContext context) { + new JavaTimeModule().setupModule(context); + new Jdk8Module().setupModule(context); + Deserializers.STRICT_DESERIALIZERS.setupModule(context); + if (context.getOwner() instanceof ObjectMapper) { + ObjectMapper mapper = (ObjectMapper) context.getOwner(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) + .setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Options.java b/src/main/java/com/google/genai/gaos/utils/Options.java new file mode 100644 index 00000000000..c559ac838a9 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Options.java @@ -0,0 +1,75 @@ +/* +* 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.utils; + +import java.util.Optional; +import java.util.List; + +@SuppressWarnings("all") +public class Options { + + public enum Option { + RETRY_CONFIG; + } + + private Optional retryConfig = Optional.empty(); + + private Options(Optional retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + } + + public Optional retryConfig() { + return retryConfig; + } + + public final void validate(List

An enum wrapper is a class that emulates enum behavior but can handle unknown values + * without runtime errors. This pattern is commonly used for API responses where new + * enum values might be added over time. + * + *

The method validates that the class follows the enum wrapper pattern by checking for: + *

    + *
  • A static factory method {@code of(String)} or {@code of(Integer)} that returns the class type
  • + *
  • An instance method {@code value()} returning String or Integer
  • + *
  • At least one public static final field of the same class type (predefined constants)
  • + *
+ * + *

If all validation passes, the method invokes the {@code value()} method on the provided instance + * and returns the result. + * + * @param clazz the class to examine for enum wrapper pattern + * @param instance the instance of the enum wrapper class from which to extract the value + * @return {@code Optional} containing the extracted value (String or Integer) if the class + * follows the enum wrapper pattern and the value extraction succeeds, {@code Optional.empty()} otherwise + */ + public static Optional getUnwrappedEnumValue(Class clazz, Object instance) { + Objects.requireNonNull(clazz, "Class cannot be null"); + + try { + // Check for factory method of(String) or of(Integer) + boolean hasFactoryMethod = Arrays.stream(clazz.getDeclaredMethods()) + .anyMatch(method -> isValidFactoryMethod(method, clazz)); + if (!hasFactoryMethod) { + return Optional.empty(); + } + + // Check for at least one static constant of same type + if (!hasStaticConstants(clazz)) { + return Optional.empty(); + } + + // Check for value() method returning String or Integer + Method valueMethod = clazz.getMethod("value"); + if (!isValidValueMethod(valueMethod)) { + return Optional.empty(); + } + + valueMethod.setAccessible(true); + return Optional.of(valueMethod.invoke(instance)); + } catch (Exception e) { + return Optional.empty(); + } + } + + /** + * Checks if the given class is an enum wrapper. + * + *

An enum wrapper is a class that emulates enum behavior but can handle unknown values + * without runtime errors. This pattern is commonly used for API responses where new + * enum values might be added over time. + * + *

The method validates that the class follows the enum wrapper pattern by checking for: + *

    + *
  • A static factory method {@code of(String)} or {@code of(Integer)} that returns the class type
  • + *
  • An instance method {@code value()} returning String or Integer
  • + *
  • At least one public static final field of the same class type (predefined constants)
  • + *
+ * + * @param clazz the class to examine for enum wrapper pattern + * @return true if the class is an enum wrapper, false otherwise + */ + public static boolean isEnumWrapper(Class clazz) { + if (clazz == null) { + return false; + } + + try { + // Check for factory method of(String) or of(Integer) + boolean hasFactoryMethod = Arrays.stream(clazz.getDeclaredMethods()) + .anyMatch(method -> isValidFactoryMethod(method, clazz)); + if (!hasFactoryMethod) { + return false; + } + + // Check for at least one static constant of same type + if (!hasStaticConstants(clazz)) { + return false; + } + + // Check for value() method returning String or Integer + Method valueMethod = clazz.getMethod("value"); + return isValidValueMethod(valueMethod); + } catch (Exception e) { + return false; + } + } + + /** + * Checks if the given object is an instance of an enum wrapper class. + * + * @param obj the object to check + * @return true if the object is an instance of an enum wrapper class, false otherwise + */ + public static boolean isEnumWrapper(Object obj) { + return obj != null && isEnumWrapper(obj.getClass()); + } + + private static boolean isNumericType(Class type) { + // Primitive numeric types + if (type.isPrimitive()) { + return type == byte.class || type == short.class || + type == int.class || type == long.class || + type == float.class || type == double.class; + } + + // Number subclasses (Integer, Long, Double, BigDecimal, etc.) + if (Number.class.isAssignableFrom(type)) { + return true; + } + + // Atomic numeric types + return type == AtomicInteger.class || type == AtomicLong.class; + } + + /** + * Checks if the given method is a valid factory method for an enum wrapper. + * + * @param method the method to check + * @param clazz the class that should be returned by the factory method + * @return true if valid factory method + */ + private static boolean isValidFactoryMethod(Method method, Class clazz) { + // Must be named "of" + if (!"of".equals(method.getName())) { + return false; + } + + // Must be static and return the enum class + if (!Modifier.isStatic(method.getModifiers()) || !method.getReturnType().equals(clazz)) { + return false; + } + + // Must have exactly one parameter of String or Integer type + Class[] parameterTypes = method.getParameterTypes(); + return parameterTypes.length == 1 && + (String.class.equals(parameterTypes[0]) || isNumericType(parameterTypes[0])); + } + + /** + * Checks if the given method is a valid value() method for an enum wrapper. + * + * @param method the value() method to validate + * @return true if valid value method + */ + private static boolean isValidValueMethod(Method method) { + // Must not be static and return String or Integer + return !Modifier.isStatic(method.getModifiers()) && + (String.class.equals(method.getReturnType()) || isNumericType(method.getReturnType())); + } + + /** + * Checks if the class has at least one public static final field of the same class type. + * + * @param clazz the class to check for static constants + * @return true if has static constants + */ + private static boolean hasStaticConstants(Class clazz) { + return Arrays.stream(clazz.getDeclaredFields()) + .anyMatch(field -> { + int modifiers = field.getModifiers(); + return Modifier.isStatic(modifiers) && + Modifier.isFinal(modifiers) && + Modifier.isPublic(modifiers) && + clazz.equals(field.getType()); + }); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/RequestBody.java b/src/main/java/com/google/genai/gaos/utils/RequestBody.java new file mode 100644 index 00000000000..97bd2bb460c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/RequestBody.java @@ -0,0 +1,377 @@ +/* +* 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.utils; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublishers; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.regex.Pattern; + + + +import com.fasterxml.jackson.databind.ObjectMapper; + +@SuppressWarnings("all") +public final class RequestBody { + private static final Map SERIALIZATION_METHOD_TO_CONTENT_TYPE = Map.of("json", "application/json", + "form", "application/x-www-form-urlencoded", "multipart", "multipart/form-data", "raw", + "application/octet-stream", "string", "text/plain"); + + private RequestBody() { + // prevent instantiation + } + + public static SerializedBody serialize(Object request, String requestField, String serializationMethod, + boolean nullable) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, + UnsupportedOperationException, IOException { + if (request == null) { + return null; + } + + if (!nullable && (request instanceof Optional) && ((Optional) request).isEmpty()) { + request = null; + } + + if (Types.getType(request.getClass()) != Types.OBJECT) { + return serializeContentType(requestField, SERIALIZATION_METHOD_TO_CONTENT_TYPE.get(serializationMethod), + request); + } + + // If no requestField specified, the request object IS the body — serialize it directly + // without attempting any field lookup. This is the case when an operation has no + // parameters alongside the body (i.e. IsRequestBody=true at the callsite). + if (requestField == null || requestField.isEmpty()) { + return serializeContentType(requestField, SERIALIZATION_METHOD_TO_CONTENT_TYPE.get(serializationMethod), + request); + } + + Field reqField = null; + + try { + reqField = request.getClass().getDeclaredField(requestField); + reqField.setAccessible(true); + } catch (NoSuchFieldException e) { + // ignore + } + if (reqField == null) { + return serializeContentType(requestField, SERIALIZATION_METHOD_TO_CONTENT_TYPE.get(serializationMethod), + request); + } + + Object requestValue = reqField.get(request); + requestValue = Utils.resolveOptionals(requestValue); + if (requestValue == null) { + return null; + } + + RequestMetadata requestMetadata = RequestMetadata.parse(reqField); + if (requestMetadata == null) { + throw new RuntimeException("Missing request metadata on request field"); + } + + return serializeContentType(requestField, requestMetadata.mediaType, requestValue); + } + + private static SerializedBody serializeContentType(String fieldName, String contentType, Object value) + throws IllegalArgumentException, IllegalAccessException, UnsupportedOperationException, IOException { + Pattern jsonPattern = Pattern.compile("^(application|text)\\/([^+]+\\+)*json.*"); + Pattern multipartPattern = Pattern.compile("^multipart\\/.*"); + Pattern formPattern = Pattern.compile("^application\\/x-www-form-urlencoded.*"); + Pattern textPattern = Pattern.compile("^text\\/plain"); + + final SerializedBody body; + + if (textPattern.matcher(contentType).matches()) { + body = new SerializedBody(contentType, BodyPublishers.ofString(value.toString())); + } else if (jsonPattern.matcher(contentType).matches()) { + ObjectMapper mapper = JSON.getMapper(); + body = new SerializedBody(contentType, BodyPublishers.ofString(mapper.writeValueAsString(value))); + } else if (multipartPattern.matcher(contentType).matches()) { + body = serializeMultipart(value); + } else if (formPattern.matcher(contentType).matches()) { + body = serializeFormData(value); + } else { + if (value instanceof String) { + body = new SerializedBody(contentType, BodyPublishers.ofString((String) value)); + } else if (value instanceof byte[]) { + body = new SerializedBody(contentType, BodyPublishers.ofByteArray((byte[]) value)); + } else if (value instanceof HttpRequest.BodyPublisher) { + body = new SerializedBody(contentType, (HttpRequest.BodyPublisher) value); + } else { + throw new RuntimeException("Unsupported content type " + contentType + " for field " + fieldName); + } + } + return body; + } + + private static SerializedBody serializeMultipart(Object value) + throws IllegalArgumentException, IllegalAccessException, UnsupportedOperationException, IOException { + Multipart.Builder builder = Multipart.builder(); + + Field[] fields = value.getClass().getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + if (Modifier.isStatic(field.getModifiers())) { + continue; + } + Object val = Utils.resolveOptionals(field.get(value)); + + if (val == null) { + continue; + } + + MultipartFormMetadata metadata = MultipartFormMetadata.parse(field); + if (metadata == null) { + throw new RuntimeException("Missing multipart form metadata on field " + field.getName()); + } + + if (metadata.file) { + if (val instanceof List || val.getClass().isArray()) { + // Handle file arrays + List arr = Utils.toList(val); + for (Object item : arr) { + serializeMultipartFile(metadata.name, builder, item); + } + } else { + // Handle single file + serializeMultipartFile(metadata.name, builder, val); + } + } else if (metadata.json) { + ObjectMapper mapper = JSON.getMapper(); + String json = mapper.writeValueAsString(val); + builder.addPart(metadata.name, json, "application/json"); + } else { + if (val instanceof List || val.getClass().isArray()) { + List arr = Utils.toList(val); + for (Object item : arr) { + builder.addPart(metadata.name, Utils.valToString(item)); + } + } else { + builder.addPart(metadata.name, Utils.valToString(val)); + } + } + } + + Multipart m = builder.build(); + return new SerializedBody(m.contentType(), m.bodyPublisher()); + } + + private static void serializeMultipartFile(String fieldName, Multipart.Builder builder, Object file) + throws IllegalArgumentException, IllegalAccessException { + if (Types.getType(file.getClass()) != Types.OBJECT) { + throw new RuntimeException("Invalid type for multipart file"); + } + + String fileName = ""; + Object content = null; + + Field[] fields = file.getClass().getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + Object val = field.get(file); + + if (val == null) { + continue; + } + + MultipartFormMetadata metadata = MultipartFormMetadata.parse(field); + if (metadata == null || (!metadata.content && (metadata.name == null || metadata.name.isBlank()))) { + continue; + } + + if (metadata.content) { + content = val; + } else { + fileName = Utils.valToString(val); + } + } + + if (fileName.isBlank() || content == null) { + throw new RuntimeException("Invalid multipart file"); + } + + // Detect content type based on file extension + String contentType = "application/octet-stream"; // default fallback + try { + String detectedType = Files.probeContentType(Path.of(fileName)); + if (detectedType != null && !detectedType.isEmpty()) { + contentType = detectedType; + } + } catch (Exception e) { + // If detection fails, use the default fallback + } + if (content instanceof byte[]) { + builder.addPart(fieldName, (byte[]) content, fileName, contentType); + } else { + builder.addPart(fieldName, (Blob) content, fileName, contentType); + } + } + + public static SerializedBody serializeFormData(Object value) + throws IOException, IllegalArgumentException, IllegalAccessException { + List params = new ArrayList<>(); + + switch (Types.getType(value.getClass())) { + case MAP: + Map map = (Map) value; + + for (Map.Entry entry : map.entrySet()) { + params.add( + new NameValue(Utils.valToString(entry.getKey()), Utils.valToString(entry.getValue()))); + } + break; + case OBJECT: + if (!Utils.allowIntrospection(value.getClass())) { + throw new RuntimeException("Invalid type for form data"); + } + Field[] fields = value.getClass().getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + Object val = Utils.resolveOptionals(field.get(value)); + + if (val == null) { + continue; + } + + FormMetadata metadata = FormMetadata.parse(field); + if (metadata == null) { + continue; + } + + if (metadata.json) { + ObjectMapper mapper = JSON.getMapper(); + String json = mapper.writeValueAsString(val); + params.add(new NameValue(metadata.name, json)); + } else { + switch (Types.getType(val.getClass())) { + case OBJECT: { + // Check if it's an enum wrapper first + Optional unwrappedEnumValue = Reflections.getUnwrappedEnumValue(val.getClass(), val); + if (unwrappedEnumValue.isPresent()) { + params.add(new NameValue(metadata.name, Utils.valToString(unwrappedEnumValue.get()))); + break; + } + + if (!Utils.allowIntrospection(val.getClass())) { + params.add(new NameValue(metadata.name, String.valueOf(val))); + } else { + + Field[] valFields = val.getClass().getDeclaredFields(); + + List items = new ArrayList<>(); + + for (Field valField : valFields) { + valField.setAccessible(true); + Object v = Utils.resolveOptionals(valField.get(val)); + if (v == null) { + continue; + } + + FormMetadata valMetadata = FormMetadata.parse(valField); + if (valMetadata == null) { + continue; + } + + if (metadata.explode) { + params.add(new NameValue(valMetadata.name, Utils.valToString(v))); + } else { + items.add(String.format("%s,%s", valMetadata.name, Utils.valToString(v))); + } + } + + if (items.size() > 0) { + params.add(new NameValue(metadata.name, String.join(",", items))); + } + } + break; + } + case MAP: { + Map valMap = (Map) val; + + List items = new ArrayList<>(); + + for (Map.Entry entry : valMap.entrySet()) { + if (metadata.explode) { + params.add(new NameValue(Utils.valToString(entry.getKey()), + Utils.valToString(entry.getValue()))); + } else { + items.add(String.format("%s,%s", entry.getKey(), entry.getValue())); + } + } + + if (items.size() > 0) { + params.add(new NameValue(metadata.name, String.join(",", items))); + } + + break; + } + case ARRAY: { + final List array = Utils.toList(val); + + List items = new ArrayList<>(); + + for (Object item : array) { + if (metadata.explode) { + params.add(new NameValue(metadata.name, Utils.valToString(item))); + } else { + items.add(Utils.valToString(item)); + } + } + + if (items.size() > 0) { + params.add(new NameValue(metadata.name, String.join(",", items))); + } + + break; + } + default: + params.add(new NameValue(metadata.name, Utils.valToString(val))); + break; + } + } + } + break; + default: + throw new RuntimeException("Invalid type for form data"); + } + + // ensure that a fresh open input stream is provided every time + // by the BodyPublisher + String contentType = "application/x-www-form-urlencoded; charset=ISO-8859-1"; + return new SerializedBody(contentType, BodyPublishers.ofInputStream(() -> { + String query = QueryEncoding.formatQuery(params, StandardCharsets.ISO_8859_1, true); + return new ByteArrayInputStream(query.getBytes(StandardCharsets.ISO_8859_1)); + })); + } + +} diff --git a/src/main/java/com/google/genai/gaos/utils/RequestMetadata.java b/src/main/java/com/google/genai/gaos/utils/RequestMetadata.java new file mode 100644 index 00000000000..5d0e9508507 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/RequestMetadata.java @@ -0,0 +1,36 @@ +/* +* 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.utils; + +import java.lang.reflect.Field; + +@SuppressWarnings("all") +class RequestMetadata { + + String mediaType = "application/octet-stream"; + + private RequestMetadata() { + } + + // request:mediaType=multipart/form-data + static RequestMetadata parse(Field field) throws IllegalArgumentException, IllegalAccessException { + return Metadata.parse("request", new RequestMetadata(), field); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Response.java b/src/main/java/com/google/genai/gaos/utils/Response.java new file mode 100644 index 00000000000..b78b891226a --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Response.java @@ -0,0 +1,41 @@ +/* +* 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.utils; +import java.io.InputStream; +import java.net.http.HttpResponse; + +@SuppressWarnings("all") +public interface Response { + + /** + * Returns the value of the Content-Type header. + **/ + String contentType(); + + /** + * Returns the HTTP status code. + **/ + int statusCode(); + + /** + * Returns the raw response. + **/ + HttpResponse rawResponse(); +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/ResponseWithBody.java b/src/main/java/com/google/genai/gaos/utils/ResponseWithBody.java new file mode 100644 index 00000000000..6b756c22735 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/ResponseWithBody.java @@ -0,0 +1,112 @@ +/* +* 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.utils; + +import javax.net.ssl.SSLSession; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpHeaders; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.function.Function; + +/** + * A wrapper for {@link HttpResponse} that allows mappi ng the response body from type {@code R} to type {@code B}. + *

+ * This class delegates all methods to the original response, except for {@link #body()}, which returns the mapped body. + * The mapping is performed using the provided {@code bodyMapper} function at construction time. + * + * @param the type of the original response body + * @param the type of the mapped response body + */ +@SuppressWarnings("all") +public class ResponseWithBody implements HttpResponse { + private final HttpResponse original; + private final Function bodyMapper; + private final B body; + + /** + * Constructs a new {@code ResponseWithBody} by wrapping an existing {@link HttpResponse} and applying + * a mapping function to its body. + * + * @param original the original response to wrap + * @param bodyMapper a function to map the original body to the new body type + */ + public ResponseWithBody(HttpResponse original, Function bodyMapper) { + this.original = original; + this.bodyMapper = bodyMapper; + this.body = bodyMapper.apply(original.body()); + } + + /** + * Constructs a new {@code ResponseWithBody} by wrapping an existing {@link HttpResponse} with + * a pre-computed body value. + * + * @param original the original response to wrap + * @param body the pre-computed body value + */ + public ResponseWithBody(HttpResponse original, B body) { + this.original = original; + this.body = body; + this.bodyMapper = null; + } + + @Override + public int statusCode() { + return original.statusCode(); + } + + @Override + public HttpRequest request() { + return original.request(); + } + + @Override + public Optional> previousResponse() { + return original.previousResponse() + .map(prev -> new ResponseWithBody<>(prev, bodyMapper)); + } + + @Override + public HttpHeaders headers() { + return original.headers(); + } + + @Override + public B body() { + return body; + } + + @Override + public Optional sslSession() { + return original.sslSession(); + } + + @Override + public URI uri() { + return original.uri(); + } + + @Override + public HttpClient.Version version() { + return original.version(); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Retries.java b/src/main/java/com/google/genai/gaos/utils/Retries.java new file mode 100644 index 00000000000..fd4d296b2d2 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Retries.java @@ -0,0 +1,323 @@ +/* +* 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.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.net.http.HttpResponse; +import java.net.http.HttpRequest; +import java.net.ConnectException; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.concurrent.TimeUnit; +import java.util.List; + +@SuppressWarnings("all") +public class Retries { + + private static final SpeakeasyLogger logger = SpeakeasyLogger.getLogger(Retries.class); + + private final RetryAction action; + private final RetryConfig retryConfig; + private final List statusCodes; + + private Retries( + RetryAction action, + RetryConfig retryConfig, + List statusCodes) { + Utils.checkNotNull(action, "action"); + Utils.checkNotNull(retryConfig, "retryConfig"); + Utils.checkNotNull(statusCodes, "statusCodes"); + if(statusCodes.size() == 0) { + throw new IllegalArgumentException("statusCodes list cannot be empty"); + } + this.action = action; + this.retryConfig = retryConfig; + this.statusCodes = statusCodes; + } + @FunctionalInterface + public interface RetryAction { + HttpResponse call(int attempt) throws Exception; + } + + + + public HttpResponse run() throws Exception { + + switch(retryConfig.strategy()) { + case BACKOFF: + if(!retryConfig.backoff().isPresent()){ + throw new IllegalArgumentException("Backoff strategy is not defined"); + } + BackoffStrategy backoff = retryConfig.backoff().get(); + return retryWithBackoff(backoff.retryConnectError(), backoff.retryReadTimeoutError()); + + case ATTEMPT_COUNT_BACKOFF: + if(!retryConfig.backoff().isPresent()){ + throw new IllegalArgumentException("Backoff strategy is not defined"); + } + backoff = retryConfig.backoff().get(); + return retryWithAttemptCountBackoff(backoff.retryConnectError(), backoff.retryReadTimeoutError()); + + case NONE: + return action.call(0); + + default: + throw new IllegalArgumentException("Invalid retry strategy"); + } + } + + private HttpResponse getResponse(boolean retryConnectError, boolean retryReadTimeoutError, int attempt) throws Exception { + try { + HttpResponse response = action.call(attempt); + + boolean shouldRetry = false; + for (String statusCode : statusCodes) { + if (statusCode.toUpperCase().contains("X")){ + int codeRange = Integer.parseInt(statusCode.substring(0, 1)); + int statusMajor = response.statusCode() / 100; + if (codeRange == statusMajor) { + shouldRetry = true; + } + } else { + int code = Integer.parseInt(statusCode); + if (code == response.statusCode()) { + shouldRetry = true; + } + } + } + + if (shouldRetry) { + throw new RetryableException(response); + } + + return response; + + } catch(IOException e) { + if(e instanceof ConnectException && retryConnectError) { + throw e; + } + String message = e.getMessage(); + if(message != null) { + if(message.contains("Connect timed out") && retryConnectError) { + throw e; + } + + if(message.contains("Read timed out") && retryReadTimeoutError) { + throw e; + } + } + throw new NonRetryableException(e); + } catch(RetryableException e) { + throw e; + } catch(Exception e) { + throw new NonRetryableException(e); + } + } + + private long retryAfterMs(HttpResponse response) { + String retryAfterMs = response.headers().firstValue("retry-after-ms").orElse(null); + if (retryAfterMs != null && !retryAfterMs.isEmpty()) { + try { + long milliseconds = Long.parseLong(retryAfterMs); + return milliseconds < 0 ? 0 : milliseconds; + } catch (NumberFormatException ignored) { + } + } + + String retryAfter = response.headers().firstValue("retry-after").orElse(null); + if (retryAfter == null || retryAfter.isEmpty()) { + return 0; + } + try { + long seconds = Long.parseLong(retryAfter); + return seconds < 0 ? 0 : seconds * 1000; + } catch (NumberFormatException ignored) { + } + try { + ZonedDateTime retryDate = ZonedDateTime.parse(retryAfter, DateTimeFormatter.RFC_1123_DATE_TIME); + long deltaMs = retryDate.toInstant().toEpochMilli() - System.currentTimeMillis(); + return deltaMs > 0 ? deltaMs : 0; + } catch (Exception ignored) { + } + return 0; + } + + private HttpResponse retryWithBackoff(boolean retryConnectError, boolean retryReadTimeoutError) throws Exception { + BackoffStrategy backoff = retryConfig.backoff().get(); + long initialIntervalMs = backoff.initialIntervalMs(); + long startMs = System.currentTimeMillis(); + int numAttempts = 0; + + while(true) { + try { + if (numAttempts > 0) { + logger.debug("Retry attempt {} after backoff", numAttempts); + } + return getResponse(retryConnectError, retryReadTimeoutError, numAttempts); + } catch(NonRetryableException e) { + logger.debug("Non-retryable exception encountered: {}", e.exception().getClass().getSimpleName()); + throw Exceptions.coerceException(e.exception()); + } catch(IOException | RetryableException e) { + long nowMs = System.currentTimeMillis(); + if (nowMs - startMs > backoff.maxElapsedTimeMs()) { + logger.debug("Retry exhausted after {}ms, {} attempts", nowMs - startMs, numAttempts + 1); + if ( e instanceof RetryableException ) { + return ((RetryableException)e).response(); + } + throw e; + } + + long sleepMs; + if (e instanceof RetryableException) { + sleepMs = retryAfterMs(((RetryableException) e).response()); + } else { + sleepMs = 0; + } + + if (sleepMs <= 0) { + double intervalMs = initialIntervalMs * Math.pow(backoff.baseFactor(), numAttempts); + double jitterMs = backoff.jitterFactor() * intervalMs; + intervalMs = intervalMs - jitterMs + Math.random()*(2*jitterMs + 1); + + double maxIntervalMs = backoff.maxIntervalMs(); + if (intervalMs > maxIntervalMs) { + intervalMs = maxIntervalMs; + } + sleepMs = (long) intervalMs; + } + + if (logger.isTraceEnabled()) { + String reason = e instanceof RetryableException + ? "status " + ((RetryableException)e).response().statusCode() + : e.getClass().getSimpleName(); + logger.trace("Retrying due to {} - waiting {}ms before attempt {}", reason, sleepMs, numAttempts + 1); + } + TimeUnit.MILLISECONDS.sleep(sleepMs); + numAttempts += 1; + } + } + } + + private HttpResponse retryWithAttemptCountBackoff(boolean retryConnectError, boolean retryReadTimeoutError) throws Exception { + BackoffStrategy backoff = retryConfig.backoff().get(); + long initialIntervalMs = backoff.initialIntervalMs(); + int numAttempts = 0; + int maxRetries = retryConfig.maxRetries().orElse(0); + + while(true) { + try { + if (numAttempts > 0) { + logger.debug("Retry attempt {} after backoff", numAttempts); + } + return getResponse(retryConnectError, retryReadTimeoutError, numAttempts); + } catch(NonRetryableException e) { + logger.debug("Non-retryable exception encountered: {}", e.exception().getClass().getSimpleName()); + throw Exceptions.coerceException(e.exception()); + } catch(IOException | RetryableException e) { + if (numAttempts >= maxRetries) { + logger.debug("Retry exhausted after {} attempts", numAttempts + 1); + if ( e instanceof RetryableException ) { + return ((RetryableException)e).response(); + } + throw e; + } + + long sleepMs; + if (e instanceof RetryableException) { + sleepMs = retryAfterMs(((RetryableException) e).response()); + } else { + sleepMs = 0; + } + + if (sleepMs <= 0) { + double intervalMs = initialIntervalMs * Math.pow(backoff.baseFactor(), numAttempts); + double jitterMs = backoff.jitterFactor() * intervalMs; + intervalMs = intervalMs - Math.random() * jitterMs; + + double maxIntervalMs = backoff.maxIntervalMs(); + if (intervalMs > maxIntervalMs) { + intervalMs = maxIntervalMs; + } + sleepMs = (long) intervalMs; + } + + TimeUnit.MILLISECONDS.sleep(sleepMs); + numAttempts += 1; + } + } + } + + public final static Builder builder() { + return new Builder(); + } + + public final static class Builder { + + private RetryAction action; + private RetryConfig retryConfig; + private List statusCodes; + + private Builder() {} + + /** + * Sets the HTTP callback to be retried. + * + * @param action The function called on retry. + * @return The builder instance. + */ + public Builder action(RetryAction action) { + Utils.checkNotNull(action, "action"); + this.action = action; + return this; + } + + /** + * Defines the retry configuration. + * + * @param retryConfig The retry configuration to use. + * @return The builder instance. + */ + public Builder retryConfig(RetryConfig retryConfig) { + Utils.checkNotNull(retryConfig, "retryConfig"); + this.retryConfig = retryConfig; + return this; + } + + /** + * Defines the status codes that should be considered as errors. + * + * @param statusCodes The list of status codes to treat as errors. + * @return The builder instance. + */ + public Builder statusCodes(List statusCodes) { + Utils.checkNotNull(statusCodes, "statusCodes"); + if(statusCodes.size() == 0) { + throw new IllegalArgumentException("statusCodes list cannot be empty"); + } + this.statusCodes = statusCodes; + return this; + } + + public Retries build() { + return new Retries(action, retryConfig, statusCodes); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/RetryConfig.java b/src/main/java/com/google/genai/gaos/utils/RetryConfig.java new file mode 100644 index 00000000000..ae98d708824 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/RetryConfig.java @@ -0,0 +1,155 @@ +/* +* 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.utils; + +import java.util.Optional; + +@SuppressWarnings("all") +public class RetryConfig { + + public enum Strategy { + BACKOFF, + ATTEMPT_COUNT_BACKOFF, + NONE; + } + + private final Strategy strategy; + private final Optional backoff; + private final Optional maxRetries; + + private RetryConfig( + Strategy strategy, + Optional backoff, + Optional maxRetries) { + this.strategy = strategy; + this.backoff = backoff; + this.maxRetries = maxRetries; + + } + public static RetryConfig noRetries() { + return RetryConfig.builder().noRetries().build(); + } + + public Strategy strategy() { + return strategy; + } + + public Optional backoff() { + return backoff; + } + + public Optional maxRetries() { + return maxRetries; + } + + public final static Builder builder() { + return new Builder(); + } + + public final static class Builder { + + private Strategy strategy = Strategy.NONE; + private boolean enabled = true; + private Optional backoff = Optional.empty(); + private Optional maxRetries = Optional.empty(); + + private Builder() {} + + /** + * Disables retries (sets strategy to "none"). + * + * @return The builder instance. + */ + public Builder noRetries() { + this.strategy = Strategy.NONE; + return this; + } + + /** + * Enables the selected strategy. + * + * @return The builder instance. + */ + public Builder enable() { + this.enabled = true; + return this; + } + + /** + * Enables or disables the selected strategy. + * + * @param enable Whether to enable the current strategy. + * @return The builder instance. + */ + public Builder enable(boolean enable) { + this.enabled = enable; + return this; + } + + /** + * Selects and configures the backoff retry strategy. + * + * @param backoff The backoff strategy to use. + * @return The builder instance. + */ + public Builder backoff(BackoffStrategy backoff) { + Utils.checkNotNull(backoff, "backoff"); + this.strategy = Strategy.BACKOFF; + this.backoff = Optional.ofNullable(backoff); + return this; + } + + /** + * Selects the default backoff retry strategy. + * + * @return The builder instance. + */ + public Builder backoff() { + this.strategy = Strategy.BACKOFF; + this.backoff = Optional.ofNullable(BackoffStrategy.withDefaults()); + return this; + } + + /** + * Selects and configures the attempt-count backoff retry strategy. + * + * @param maxRetries The maximum retry attempts after the initial request. + * @param backoff The backoff strategy to use. + * @return The builder instance. + */ + public Builder attemptCountBackoff(int maxRetries, BackoffStrategy backoff) { + Utils.checkNotNull(backoff, "backoff"); + if (maxRetries < 0) { + throw new IllegalArgumentException("maxRetries must be non-negative"); + } + this.strategy = Strategy.ATTEMPT_COUNT_BACKOFF; + this.maxRetries = Optional.of(maxRetries); + this.backoff = Optional.ofNullable(backoff); + return this; + } + + public RetryConfig build() { + if(!enabled) { + return RetryConfig.noRetries(); + } + return new RetryConfig(strategy, backoff, maxRetries); + } + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/RetryableException.java b/src/main/java/com/google/genai/gaos/utils/RetryableException.java new file mode 100644 index 00000000000..b0ba46be091 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/RetryableException.java @@ -0,0 +1,36 @@ +/* +* 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.utils; + +import java.io.InputStream; +import java.net.http.HttpResponse; + +@SuppressWarnings("all") +public final class RetryableException extends Exception { + private final HttpResponse response; + + public RetryableException(HttpResponse response) { + this.response = response; + } + + public HttpResponse response() { + return response; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Security.java b/src/main/java/com/google/genai/gaos/utils/Security.java new file mode 100644 index 00000000000..e798b4028e6 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Security.java @@ -0,0 +1,348 @@ +/* +* 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.utils; + +import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Base64; +import java.util.Deque; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@SuppressWarnings("all") +public final class Security { + + private Security() { + // prevent instantiation + } + + public static HTTPRequest configureSecurity(HTTPRequest request, Object security, String... allowedFields) throws Exception { + if (security != null) { + Field[] fields; + if (allowedFields.length > 0) { + List ordered = new ArrayList<>(); + for (String name : allowedFields) { + try { + ordered.add(security.getClass().getDeclaredField(name)); + } catch (NoSuchFieldException e) { + // skip unknown fields + } + } + fields = ordered.toArray(new Field[0]); + } else { + fields = security.getClass().getDeclaredFields(); + } + + for (Field field : fields) { + field.setAccessible(true); + Object value = Utils.resolveOptionals(field.get(security)); + if (value == null) { + continue; + } + + SecurityMetadata securityMetadata = SecurityMetadata.parse(field); + if (securityMetadata == null) { + continue; + } + + if (securityMetadata.option) { + parseSecurityOption(request, value); + if (!securityMetadata.composite) { + return request; + } + } else if (securityMetadata.scheme) { + if ((securityMetadata.subtype != null && securityMetadata.subtype.equals("basic")) + && Types.getType(value.getClass()) != Types.OBJECT) { + parseSecurityScheme(request, securityMetadata, security); + } else { + parseSecurityScheme(request, securityMetadata, value); + } + if (!securityMetadata.composite) { + return request; + } + } + } + } + return request; + } + + private static void parseSecurityOption(HTTPRequest request, Object option) + throws Exception { + Field[] fields = option.getClass().getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + Object value = Utils.resolveOptionals(field.get(option)); + + if (value == null) { + continue; + } + + SecurityMetadata securityMetadata = SecurityMetadata.parse(field); + if (securityMetadata == null || !securityMetadata.scheme) { + continue; + } + + if (securityMetadata.subtype != null && securityMetadata.subtype.equals("basic") + && Types.getType(value.getClass()) != Types.OBJECT) { + parseSecurityScheme(request, securityMetadata, option); + } else { + parseSecurityScheme(request, securityMetadata, value); + } + } + } + + private static void parseSecurityScheme(HTTPRequest requestBuilder, SecurityMetadata schemeMetadata, + Object scheme) throws Exception { + + if (Types.getType(scheme.getClass()) == Types.OBJECT) { + if (schemeMetadata.type.equals("http") && schemeMetadata.subtype.equals("basic")) { + parseBasicAuthScheme(requestBuilder, scheme); + return; + } + + Field[] fields = scheme.getClass().getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + Object value = Utils.resolveOptionals(field.get(scheme)); + + if (value == null) { + continue; + } + + SecurityMetadata securityMetadata = SecurityMetadata.parse(field); + if (securityMetadata == null || securityMetadata.name.isEmpty()) { + continue; + } + + parseSecuritySchemeValue(requestBuilder, schemeMetadata, securityMetadata, value); + } + } else { + parseSecuritySchemeValue(requestBuilder, schemeMetadata, schemeMetadata, scheme); + } + } + + private static void parseSecuritySchemeValue(HTTPRequest request, SecurityMetadata schemeMetadata, + SecurityMetadata securityMetadata, + Object value) throws Exception { + switch (schemeMetadata.type) { + case "apiKey": + switch (schemeMetadata.subtype) { + case "header": + request.addHeader(securityMetadata.name, Utils.valToString(value)); + break; + case "query": + request.addQueryParam( + securityMetadata.name, Utils.valToString(value), false); + break; + case "cookie": + request.addHeader("Cookie", + String.format("%s=%s", securityMetadata.name, Utils.valToString(value))); + break; + default: + throw new RuntimeException( + "Unsupported apiKey security scheme subtype: " + securityMetadata.subtype); + } + break; + case "openIdConnect": + request.addHeader(securityMetadata.name, Utils.prefixBearer(Utils.valToString(value))); + break; + case "oauth2": + if (!"client_credentials".equals(schemeMetadata.subtype)) { + request.addHeader(securityMetadata.name, Utils.prefixBearer(Utils.valToString(value))); + } + break; + case "http": + switch (schemeMetadata.subtype) { + case "bearer": + request.addHeader(securityMetadata.name, Utils.prefixBearer(Utils.valToString(value))); + break; + case "basic": + request.addHeader(securityMetadata.name, Utils.valToString(value)); + break; + case "custom": + // customers are expected to consume the security object and transform requests + // in their own BeforeRequest hook. + break; + default: + throw new RuntimeException("Unsupported http security scheme subtype: " + schemeMetadata.subtype); + } + break; + default: + throw new RuntimeException("Unsupported security scheme type: " + schemeMetadata.subtype); + } + } + + private static void parseBasicAuthScheme(HTTPRequest requestBuilder, Object scheme) + throws IllegalAccessException { + Field[] fields = scheme.getClass().getDeclaredFields(); + + String username = ""; + String password = ""; + + for (Field field : fields) { + field.setAccessible(true); + Object value = Utils.resolveOptionals(field.get(scheme)); + + if (value == null) { + continue; + } + + SecurityMetadata securityMetadata = SecurityMetadata.parse(field); + if (securityMetadata == null || securityMetadata.name.isEmpty()) { + continue; + } + + switch (securityMetadata.name) { + case "username": + username = Utils.valToString(value); + break; + case "password": + password = Utils.valToString(value); + break; + default: + throw new RuntimeException("Unsupported security scheme field for basic auth: " + securityMetadata.name); + } + } + + requestBuilder.addHeader("Authorization", + "Basic " + + Base64.getEncoder() + .encodeToString(String.format("%s:%s", username, password) + .getBytes(StandardCharsets.UTF_8))); + } + + public static Optional findComplexObjectWithNonEmptyAnnotatedField(Object object, String... regexes) { + if (object == null || object instanceof String) { + return Optional.empty(); + } + Deque stack = new LinkedList<>(); + // be defensive about circular references (not expected) + Set processed = new HashSet<>(); + stack.push(object); + processed.add(object); + while (!stack.isEmpty()) { + Object o = stack.pop(); + Field[] fields = o.getClass().getDeclaredFields(); + List annotatedFields = Arrays.stream(fields) // + .filter(f -> { + SpeakeasyMetadata[] anns = f.getDeclaredAnnotationsByType(SpeakeasyMetadata.class); + return anns != null && anns.length > 0; + }) // + .collect(Collectors.toList()); + for (Field f : annotatedFields) { + SpeakeasyMetadata[] anns = f.getDeclaredAnnotationsByType(SpeakeasyMetadata.class); + Object value = getUnwrappedFieldValue(o, f); + if (value != null && !(value instanceof String)) { + // we are looking for a complex object (so can't be a String) + boolean regexMatches = Arrays // + .stream(regexes) // + .allMatch(regex -> matches(anns, regex)); + if (regexMatches) { + return Optional.of(value); + } else if (!processed.contains(value)) { + stack.push(value); + processed.add(value); + } + } + } + } + return Optional.empty(); + } + + private static Object getUnwrappedFieldValue(Object o, Field f) { + try { + f.setAccessible(true); + Object value = f.get(o); + if (value != null && value instanceof Optional) { + return ((Optional) value).orElse(null); + } else { + return value; + } + } catch (IllegalArgumentException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + public static Stream findFieldsWhereMetadataContainsRegexes(Object o, String... regexes) { + Field[] fields = o.getClass().getDeclaredFields(); + return Arrays.stream(fields) // + .filter(f -> { + SpeakeasyMetadata[] anns = f.getDeclaredAnnotationsByType(SpeakeasyMetadata.class); + if (anns == null) { + return false; + } + return Arrays // + .stream(regexes) // + .allMatch(regex -> matches(anns, regex)); + }); + } + + public static Optional findStringValueWhereMetadataContainsRegexes(Object o, String... regexes) { + return findValueWhereMetadataContainsRegexes(o, regexes).map(x -> (String) x); + } + + public static Optional findStringValueWhereMetadataNameIs(Object o, String name) { + return Security.findStringValueWhereMetadataContainsRegexes(o, "\\bname=" + name + "\\b"); + } + + public static Optional findValueWhereMetadataContainsRegexes(Object o, String... regexes) { + return findFieldsWhereMetadataContainsRegexes(o, regexes) + .flatMap(f -> { + f.setAccessible(true); + Object result; + try { + result = f.get(o); + } catch (IllegalArgumentException | IllegalAccessException e) { + throw new RuntimeException(e); + } + if (result instanceof Optional) { + @SuppressWarnings("unchecked") + Optional r = (Optional) result; + if (r.isEmpty()) { + return Stream.empty(); + } else { + return Stream.of(r.get()); + } + } else { + return Stream.of(result); + } + }).findAny(); + } + + private static boolean matches(SpeakeasyMetadata[] anns, String regex) { + Pattern pattern = Pattern.compile(regex); + for (SpeakeasyMetadata ann : anns) { + if (pattern.matcher(ann.value()).find()) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/SecurityMetadata.java b/src/main/java/com/google/genai/gaos/utils/SecurityMetadata.java new file mode 100644 index 00000000000..0b0b3e7f63f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/SecurityMetadata.java @@ -0,0 +1,41 @@ +/* +* 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.utils; + +import java.lang.reflect.Field; + +@SuppressWarnings("all") +class SecurityMetadata { + + String type; + String subtype; + boolean option; + boolean scheme; + boolean composite; + String name; + + private SecurityMetadata() { + } + + // security:scheme=true,type=apiKey,subtype=header + static SecurityMetadata parse(Field field) throws IllegalArgumentException, IllegalAccessException { + return Metadata.parse("security", new SecurityMetadata(), field); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/SerializedBody.java b/src/main/java/com/google/genai/gaos/utils/SerializedBody.java new file mode 100644 index 00000000000..da3f457215b --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/SerializedBody.java @@ -0,0 +1,44 @@ +/* +* 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.utils; + +import java.net.http.HttpRequest.BodyPublisher; + +@SuppressWarnings("all") +public class SerializedBody { + + private final String contentType; + private final BodyPublisher body; + + public SerializedBody(String contentType, BodyPublisher body) { + Utils.checkNotNull(contentType, "content"); + Utils.checkNotNull(body, "body"); + this.contentType = contentType; + this.body = body; + } + + public String contentType() { + return contentType; + } + + public BodyPublisher body() { + return body; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/SessionManager.java b/src/main/java/com/google/genai/gaos/utils/SessionManager.java new file mode 100644 index 00000000000..4a9389789c7 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/SessionManager.java @@ -0,0 +1,230 @@ +/* +* 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.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +import com.google.genai.gaos.models.errors.AuthException; + +import com.fasterxml.jackson.annotation.JsonProperty; + +@SuppressWarnings("all") +public final class SessionManager { + + // VisibleForTesting + public static final int REFRESH_BEFORE_EXPIRY_SECONDS = 60; + + private final Map>> sessions = new HashMap<>(); + + public interface HasSessionKey { + String sessionKey(); + } + + public final static class Session { + private final T credentials; + private final Optional token; + private final List scopes; + private final Optional expiresAt; + + public Session(T credentials, Optional token, List scopes, Optional expiresAt) { + this.credentials = credentials; + this.token = token; + this.scopes = scopes; + this.expiresAt = expiresAt; + } + + public T credentials() { + return credentials; + } + + public Optional token() { + return token; + } + + public List scopes() { + return scopes; + } + + public Optional expiresAt() { + return expiresAt; + } + + } + + public Session getSession(T credentials, List scopes, Function, Session> tokenProvider ) { + final String sessionKey = credentials.sessionKey(); + final String scopeKey = getScopeKey(scopes); + + Optional> existingSession = getExistingSession(sessionKey, scopes); + final Session session; + if (!existingSession.isPresent()) { + session = tokenProvider.apply(scopes); + sessions.computeIfAbsent(sessionKey, k -> new HashMap<>()).put(scopeKey, session); + } else { + session = existingSession.get(); + } + return session; + } + + private Optional> getExistingSession(String sessionKey, List requiredScopes) { + Map> clientSessions = sessions.get(sessionKey); + if (clientSessions == null) { + return Optional.empty(); + } + + String scopeKey = getScopeKey(requiredScopes); + + // First look for an exact match + Session exactSession = clientSessions.get(scopeKey); + if (exactSession != null) { + if (hasTokenExpired(exactSession.expiresAt, OffsetDateTime.now())) { + removeSession(sessionKey, scopeKey); + } else { + return Optional.of(exactSession); + } + } + + // If no exact match was found, look for a superset match + List expiredSessionKeys = new ArrayList<>(); + Session validSession = null; + for (Map.Entry> entry : clientSessions.entrySet()) { + Session session = entry.getValue(); + if (hasTokenExpired(session.expiresAt, OffsetDateTime.now())) { + expiredSessionKeys.add(entry.getKey()); + } else if (hasRequiredScopes(session.scopes, requiredScopes)) { + validSession = session; + } + } + + for (String key : expiredSessionKeys) { + removeSession(sessionKey, key); + } + + return Optional.ofNullable(validSession); + } + + private static String getScopeKey(List scopes) { + if (scopes == null || scopes.isEmpty()) { + return ""; + } + + List sortedScopes = new ArrayList<>(scopes); + sortedScopes.sort(String::compareTo); + return String.join("&", sortedScopes); + } + + /** + * Checks if the token has expired. + * If no expires_in field was returned by the authorization server, the token is considered to never expire. + * A buffer (REFRESH_BEFORE_EXPIRY_SECONDS) is applied to refresh tokens before they actually expire. + */ + // VisibleForTesting + public static boolean hasTokenExpired(Optional expiresAt, OffsetDateTime now) { + return !expiresAt.isEmpty() && now.plusSeconds(REFRESH_BEFORE_EXPIRY_SECONDS).isAfter(expiresAt.get()); + } + + // VisibleForTesting + public static boolean hasRequiredScopes(List sessionScopes, List requiredScopes) { + return sessionScopes.containsAll(requiredScopes); + } + + public void remove(String sessionKey) { + sessions.remove(sessionKey); + } + + public void removeSession(String sessionKey, String scopeKey) { + Map> clientSessions = sessions.get(sessionKey); + if (clientSessions != null) { + clientSessions.remove(scopeKey); + // Clean up empty client sessions + if (clientSessions.isEmpty()) { + sessions.remove(sessionKey); + } + } + } + + public static Session requestOAuth2Token(HTTPClient client, T credentials, List scopes, + Map body, Map headers, URI tokenUri) { + try { + HttpRequest.Builder requestBuilder = HttpRequest // + .newBuilder(tokenUri) // + .header("Content-Type", "application/x-www-form-urlencoded") // + .POST(RequestBody.serializeFormData(body).body()); // + + for (Map.Entry header : headers.entrySet()) { + requestBuilder.header(header.getKey(), header.getValue()); + } + + HttpRequest request = requestBuilder.build(); + HttpResponse response = client.send(request); + if (response.statusCode() != HttpURLConnection.HTTP_OK) { + String responseBody = Utils.toUtf8AndClose(response.body()); + throw new AuthException( + "Unexpected status code " + response.statusCode() + ": " + responseBody, + response.statusCode(), + responseBody.getBytes(StandardCharsets.UTF_8), + response); + } + TokenResponse t = Utils.mapper().readValue(response.body(), TokenResponse.class); + if (!t.tokenType.orElse("").toLowerCase().equals("bearer")) { + throw new AuthException( + "Expected 'Bearer' token type but was '" + t.tokenType.orElse("") + "'", + response.statusCode(), + Utils.readBytesAndClose(response.body()), + response); + } + final Optional expiresAt = t.expiresInSeconds + .map(x -> OffsetDateTime.now().plus(x, ChronoUnit.SECONDS)); + return new Session(credentials, t.accessToken, scopes, expiresAt); + } catch (IOException | IllegalArgumentException | IllegalAccessException | InterruptedException | URISyntaxException e) { + throw new RuntimeException(e); + } + } + + final static class TokenResponse { + + @JsonProperty("access_token") + Optional accessToken; + + @JsonProperty("token_type") + Optional tokenType; + + @JsonProperty("expires_in") + Optional expiresInSeconds;; + + } + +} diff --git a/src/main/java/com/google/genai/gaos/utils/SpeakeasyHTTPClient.java b/src/main/java/com/google/genai/gaos/utils/SpeakeasyHTTPClient.java new file mode 100644 index 00000000000..e97b7e73a8d --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/SpeakeasyHTTPClient.java @@ -0,0 +1,222 @@ +/* +* 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.utils; + +import com.google.genai.gaos.utils.Blob; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpHeaders; +import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublishers; +import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Locale; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.concurrent.CompletableFuture; + +@SuppressWarnings("all") +public class SpeakeasyHTTPClient implements HTTPClient { + + // global debug flag. Retained for backwards compatibility. + private static boolean debugEnabled = false; + + // Instance-level debug flag. Can be set by clients to enable debug logging for a + // single SDK instance. + private Boolean localDebugEnabled; + + // uppercase + private static Set redactedHeaders = Set.of("AUTHORIZATION", "X-API-KEY"); + + private static Consumer logger = System.out::println; + + private final HttpClient client = HttpClient.newHttpClient(); + + /** + * Sets debug logging on or off for requests and responses including bodies for JSON content. + *

+ * WARNING: This setting may expose sensitive information in logs (such as + * {@code Authorization} headers) and should only be enabled temporarily for local debugging + * purposes. + *

+ * By default, {@code Authorization} headers are redacted in the logs (printed with a value + * of {@code [*******]}). Header suppression can be controlled with the + * {@link #setRedactedHeaders(Collection)} method. + * + * @param enabled {@code true} to enable debug logging, {@code false} to disable it + * @see #setRedactedHeaders(Collection) + * @see #addRedactedHeader(String) + * @see #getDebugLoggingEnabled() + */ + public static void setDebugLogging(boolean enabled) { + debugEnabled = enabled; + } + + public static boolean getDebugLoggingEnabled() { + return debugEnabled; + } + + @Override + public boolean isDebugLoggingEnabled() { + return Optional.ofNullable(localDebugEnabled).orElse(debugEnabled); + } + + @Override + public void enableDebugLogging(boolean enabled) { + localDebugEnabled = enabled; + } + + /** + * When debug logging is enabled, this method controls the suppression of header values in the logs. + *

+ * By default, {@code Authorization} headers are redacted in the logs (printed with a value + * of {@code [*******]}). + * + * @param headerNames the names (case-insensitive) of the headers whose values + * will be redacted in the logs + * @see #setDebugLogging(boolean) + */ + public static void setRedactedHeaders(Collection headerNames) { + redactedHeaders = headerNames.stream() // + .map(x -> x.toUpperCase(Locale.ENGLISH)) // + .collect(Collectors.toSet()); + } + + /** + * When debug logging is enabled, this method adds a single header to the list of headers + * whose values will be redacted in the logs. + *

+ * By default, {@code Authorization} headers are redacted in the logs (printed with a value + * of {@code [*******]}). + * + * @param headerName the name (case-insensitive) of the header whose value + * will be redacted in the logs + * @see #setDebugLogging(boolean) + * @see #setRedactedHeaders(Collection) + */ + public static void addRedactedHeader(String headerName) { + Set updated = new java.util.HashSet<>(redactedHeaders); + updated.add(headerName.toUpperCase(Locale.ENGLISH)); + redactedHeaders = Set.copyOf(updated); + } + + public static void setLogger(Consumer logger) { + SpeakeasyHTTPClient.logger = logger; + } + + @Override + public HttpResponse send(HttpRequest request) + throws IOException, InterruptedException, URISyntaxException { + if (isDebugLoggingEnabled()) { + request = logRequest(request, true); + } + var response = client.send(request, HttpResponse.BodyHandlers.ofInputStream()); + if (isDebugLoggingEnabled()) { + response = logResponse(response, true); + } + return response; + } + + @Override + public CompletableFuture> sendAsync(HttpRequest request) { + if (isDebugLoggingEnabled()) { + request = logRequest(request, true); + } + return client.sendAsync(request, HttpResponse.BodyHandlers.ofPublisher()) + .thenApply(response -> + // TODO: log responses when helper for Blob is setup + new ResponseWithBody<>(response, Blob::from)); + } + + private HttpRequest logRequest(HttpRequest request, boolean logBody) { + log("Sending request: " + request); + log("Request headers: " + redactHeaders(request.headers())); + // only log the body if logBody is true and the body is present and the content type is JSON + if (logBody && request.bodyPublisher().isPresent() && request.headers() // + .firstValue("Content-Type") // + .filter(x -> x.equals("application/json") || x.equals("text/plain")).isPresent()) { + // we read the body and ensure that the BodyPublisher is rebuilt to pass to the + // http client + byte[] body = Helpers.bodyBytes(request); + request = Helpers // + .copy(request) // + .method(request.method(), BodyPublishers.ofByteArray(body)) // + .build(); + // note that in the case of text/plain a different encoding from UTF-8 + // may be in use but we just log the bytes as UTF-8. Unexpected encodings + // do not throw (substitution happens). + log("Request body:\n" + new String(body, StandardCharsets.UTF_8)); + } + return request; + } + + private static HttpResponse logResponse(HttpResponse response, boolean logBody) throws IOException { + String contentType = response.headers().firstValue("Content-Type").orElse("application/octet-stream"); + log("Received response: " + response); + log("Response headers: " + redactHeaders(response.headers())); + + // skip caching for streaming responses - they may hang + if (contentType.startsWith("text/event-stream") || contentType.startsWith("application/x-ndjson")) { + return response; + } + + // make the response re-readable by loading the response body into a byte array + // and allowing the InputStream to be read many times + response = Utils.cache(response); + + // only log the response body if logBody is true and the content type is JSON or plain text + if (logBody && (contentType.startsWith("application/json") || contentType.startsWith("text/plain"))) { + // the response is re-readable so we can read and close it without + // affecting later processing of the response. + + // note that in the case of text/plain a different encoding from UTF-8 + // may be in use but we just log the bytes as UTF-8. Unexpected encodings + // do not throw (substitution happens). + log("Response body:\n" + Utils.toUtf8AndClose(response.body())); + } + return response; + } + + private static String redactHeaders(HttpHeaders headers) { + return "{" + headers.map() // + .entrySet() // + .stream() // + .map(entry -> { + final String value; + if (redactedHeaders.contains(entry.getKey().toUpperCase(Locale.ENGLISH))) { + value = "[******]"; + } else { + value = String.valueOf(entry.getValue()); + } + return entry.getKey() + "=" + value; + }) // + .collect(Collectors.joining(", ")) + "}"; + } + + private static void log(String message) { + logger.accept(message); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/SpeakeasyLogger.java b/src/main/java/com/google/genai/gaos/utils/SpeakeasyLogger.java new file mode 100644 index 00000000000..67bd7226765 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/SpeakeasyLogger.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 +* +* 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.utils; + +/** + * Wrapper for SLF4j logging that provides consistent logging patterns across the SDK. + * When SLF4j is disabled, all logging operations are no-ops. + */ +@SuppressWarnings("all") +public class SpeakeasyLogger { + // SLF4j logging is disabled - all methods are no-ops + + private SpeakeasyLogger(Class clazz) { + // No-op constructor + } + + public static SpeakeasyLogger getLogger(Class clazz) { + return new SpeakeasyLogger(clazz); + } + + public boolean isDebugEnabled() { + return false; + } + + public boolean isTraceEnabled() { + return false; + } + + public void debug(String message) {} + public void debug(String format, Object arg) {} + public void debug(String format, Object arg1, Object arg2) {} + public void debug(String format, Object... arguments) {} + + public void trace(String message) {} + public void trace(String format, Object arg) {} + public void trace(String format, Object arg1, Object arg2) {} + public void trace(String format, Object... arguments) {} + + public void info(String message) {} + public void info(String format, Object arg) {} + public void info(String format, Object arg1, Object arg2) {} + public void info(String format, Object... arguments) {} + + public void warn(String message) {} + public void warn(String format, Object arg) {} + public void warn(String format, Object arg1, Object arg2) {} + public void warn(String format, Object... arguments) {} + + public void error(String message) {} + public void error(String format, Object arg) {} + public void error(String format, Object arg1, Object arg2) {} + public void error(String format, Object... arguments) {} + public void error(String message, Throwable t) {} +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/SpeakeasyMetadata.java b/src/main/java/com/google/genai/gaos/utils/SpeakeasyMetadata.java new file mode 100644 index 00000000000..f82dd353643 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/SpeakeasyMetadata.java @@ -0,0 +1,32 @@ +/* +* 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.utils; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +@SuppressWarnings("all") +public @interface SpeakeasyMetadata { + String value() default ""; +} diff --git a/src/main/java/com/google/genai/gaos/utils/StreamingParser.java b/src/main/java/com/google/genai/gaos/utils/StreamingParser.java new file mode 100644 index 00000000000..23f5bab6ea1 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/StreamingParser.java @@ -0,0 +1,374 @@ +/* +* 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.utils; + +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.Optional; + +/** + * Generic streaming parser that handles byte buffer management and delegates + * format-specific logic to a StreamContentProcessor. + */ +@SuppressWarnings("all") +public final class StreamingParser { + + /** + * Information about a found boundary in byte data + */ + static class BoundaryInfo { + public final int position; + public final int delimiterLength; + + public BoundaryInfo(int position, int delimiterLength) { + this.position = position; + this.delimiterLength = delimiterLength; + } + } + + /** + * Interface for format-specific parsing logic + */ + interface StreamContentProcessor { + /** + * Find the next boundary in the byte buffer + * @return boundary info, or position -1 if no boundary found + */ + BoundaryInfo findBoundary(byte[] data, int limit); + + /** + * Process extracted content and return the parsed result + * @param content the extracted content (without boundary delimiters) + * @return parsed result, or empty if content should be skipped + */ + Optional processContent(String content); + + /** + * Sanitize content text (e.g., handle line endings, BOM, etc.) + * @param rawContent the raw extracted content + * @param isFirst whether this is the first content processed + * @return sanitized content + */ + default String sanitizeContent(String rawContent, boolean isFirst) { + return rawContent.replace("\r\n", "\n").replace("\r", "\n"); + } + } + + private final StreamContentProcessor processor; + private ByteBuffer byteBuffer = ByteBuffer.allocate(8192); + private boolean first = true; + + StreamingParser(StreamContentProcessor processor) { + this.processor = processor; + } + + /** + * Add ByteBuffer data to the parser buffer and extract any complete items. + * + * @param inputBuffer byte data to add (will not be modified) + * @return next complete parsed result if one becomes available + */ + public Optional add(ByteBuffer inputBuffer) { + if (inputBuffer == null || !inputBuffer.hasRemaining()) { + return extractNextFromBytes(); + } + // Ensure we have enough capacity + if (byteBuffer.remaining() < inputBuffer.remaining()) { + byteBuffer = expandByteBuffer(byteBuffer.position() + inputBuffer.remaining()); + } + // Append new data + byteBuffer.put(inputBuffer.slice()); + return extractNextFromBytes(); + } + + /** + * Extract any remaining partial content when stream ends. + * + * @return final parsed result if there was incomplete data in the buffer + */ + public Optional finish() { + if (byteBuffer.position() > 0) { + byte[] remainingBytes = new byte[byteBuffer.position()]; + byteBuffer.flip(); + byteBuffer.get(remainingBytes); + byteBuffer.clear(); + String content = processor.sanitizeContent(new String(remainingBytes, StandardCharsets.UTF_8), first); + return processor.processContent(content); + } + return Optional.empty(); + } + + /** + * Check if there are additional complete items in the buffer. + * + * @return next complete parsed result from buffer if available + */ + public Optional next() { + return extractNextFromBytes(); + } + + /** + * Check if parser has any buffered data + */ + public boolean hasBufferedData() { + return byteBuffer.position() > 0; + } + + private Optional extractNextFromBytes() { + if (byteBuffer.position() == 0) { + return Optional.empty(); + } + // Find boundary directly in bytes + BoundaryInfo boundary = processor.findBoundary(byteBuffer.array(), byteBuffer.position()); + if (boundary.position == -1) { + return Optional.empty(); + } + // Extract content bytes without copying the entire buffer + byte[] contentBytes = new byte[boundary.position]; + byteBuffer.flip(); + byteBuffer.get(contentBytes, 0, boundary.position); + // Compact buffer to remove processed content + delimiter + byteBuffer.position(boundary.position + boundary.delimiterLength); + byteBuffer.compact(); + String content = processor.sanitizeContent(new String(contentBytes, StandardCharsets.UTF_8), first); + if (first) { + first = false; + } + Optional result = processor.processContent(content); + if (result.isPresent()) { + return result; + } + // Check for additional items if this one was skipped + return extractNextFromBytes(); + } + + private ByteBuffer expandByteBuffer(int newCapacity) { + ByteBuffer newBuffer = ByteBuffer.allocate(Math.max(newCapacity, byteBuffer.capacity() * 2)); + byteBuffer.flip(); + newBuffer.put(byteBuffer); + return newBuffer; + } + + /** + * Check if a byte pattern matches at a specific position + */ + public static boolean matchesPattern(byte[] data, int pos, int limit, byte... pattern) { + if (pos + pattern.length > limit) { + return false; + } + for (int i = 0; i < pattern.length; i++) { + if (data[pos + i] != pattern[i]) { + return false; + } + } + return true; + } + + // ===== JSON Lines Content Processor ===== + + /** + * JSON Lines content processor implementation + */ + private static class JsonLContentProcessor implements StreamContentProcessor { + // Line boundary patterns + private static final byte CR = '\r'; + private static final byte LF = '\n'; + private static final byte[] CRLF = {CR, LF}; // \r\n + private static final byte[] LF_ONLY = {LF}; // \n + + // Next unexamined offset; preserved across reads to avoid rescanning. + private int scanPos = 0; + + @Override + public BoundaryInfo findBoundary(byte[] data, int limit) { + // Resume one byte early so a trailing CR can complete to CRLF. + for (int i = Math.max(0, scanPos - 1); i < limit; i++) { + // Check for CRLF first (longer pattern) + if (matchesPattern(data, i, limit, CRLF)) { + scanPos = 0; + return new BoundaryInfo(i, CRLF.length); + } + // Check for LF only + if (matchesPattern(data, i, limit, LF_ONLY)) { + scanPos = 0; + return new BoundaryInfo(i, LF_ONLY.length); + } + } + scanPos = limit; + return new BoundaryInfo(-1, 0); + } + + @Override + public Optional processContent(String content) { + String trimmed = content.trim(); + // Return non-empty JSON lines + return trimmed.isEmpty() ? Optional.empty() : Optional.of(trimmed); + } + } + + // ===== SSE Content Processor ===== + + /** + * SSE content processor implementation + */ + private static class SSEContentProcessor implements StreamContentProcessor { + private static final String BYTE_ORDER_MARK = "\uFEFF"; + private static final char LINEFEED = '\n'; + private static final byte CR = '\r'; + private static final byte LF = '\n'; + private static final byte[][] BOUNDARY_PATTERNS = { + {CR, LF}, + {LF}, + {CR} + }; + + private Optional eventId = Optional.empty(); + + // Scan state preserved across reads; offsets stay valid because the + // parser compacts and resets this state after each boundary. + private int scanPos = 0; + private int lineStart = 0; + // A trailing CR may complete to CRLF on the next read; in that case + // the LF belongs to the same line ending, not a new empty line. + private boolean pendingCRLF = false; + + @Override + public BoundaryInfo findBoundary(byte[] data, int limit) { + int i = scanPos; + if (pendingCRLF) { + pendingCRLF = false; + if (i < limit && data[i] == LF && i == lineStart) { + lineStart = i + 1; + i = i + 1; + } + } + while (i < limit) { + for (byte[] pattern : BOUNDARY_PATTERNS) { + if (matchesPattern(data, i, limit, pattern)) { + if (i == lineStart) { // empty line + int boundStart = i; + while (boundStart > 0 && (data[boundStart - 1] == CR || data[boundStart - 1] == LF)) { + boundStart--; + } + int boundLength = (lineStart - boundStart) + pattern.length; + scanPos = 0; + lineStart = 0; + pendingCRLF = false; + return new BoundaryInfo(boundStart, boundLength); + } + if (pattern.length == 1 && data[i] == CR && i == limit - 1) { + pendingCRLF = true; + } + lineStart = i + pattern.length; + i = lineStart - 1; + break; + } + } + i++; + } + scanPos = i; + return new BoundaryInfo(-1, 0); + } + + @Override + public Optional processContent(String content) { + if (content.trim().isEmpty()) { + return Optional.empty(); + } + return Optional.of(parseMessage(content)); + } + + @Override + public String sanitizeContent(String rawContent, boolean isFirst) { + String sanitized = rawContent.replace("\r\n", "\n").replace("\r", "\n"); + if (isFirst && sanitized.startsWith(BYTE_ORDER_MARK)) { + sanitized = sanitized.substring(BYTE_ORDER_MARK.length()); + } + return sanitized; + } + + private EventStreamMessage parseMessage(String text) { + String[] lines = text.split("\n"); + Optional event = Optional.empty(); + Optional retryMs = Optional.empty(); + Optional data = Optional.empty(); + for (String line : lines) { + if (line.startsWith(":")) { + continue; + } + String key; + String value; + int colonIndex = line.indexOf(':'); + if (colonIndex >= 0) { + key = line.substring(0, colonIndex); + value = line.substring(colonIndex + 1); + if (value.startsWith(" ")) { + value = value.substring(1); + } + } else { + key = line; + value = ""; + } + switch (key) { + case "event": + event = Optional.of(value); + break; + case "id": + if (value.indexOf('\0') < 0) { + eventId = Optional.of(value); + } + break; + case "retry": + try { + retryMs = Optional.of(Integer.parseInt(value)); + } catch (NumberFormatException e) { + // ignore invalid retry values + } + break; + case "data": + if (data.isEmpty()) { + data = Optional.of(new StringBuilder()); + } else { + data.get().append(LINEFEED); + } + data.get().append(value); + break; + } + } + return new EventStreamMessage(event, eventId, retryMs, data.map(StringBuilder::toString)); + } + } + + // ===== Factory Methods ===== + + /** + * Create a streaming parser for JSON Lines format + */ + public static StreamingParser forJsonLines() { + return new StreamingParser<>(new JsonLContentProcessor()); + } + + /** + * Create a streaming parser for SSE format + */ + public static StreamingParser forSSE() { + return new StreamingParser<>(new SSEContentProcessor()); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/TypedObject.java b/src/main/java/com/google/genai/gaos/utils/TypedObject.java new file mode 100644 index 00000000000..abe12726d6c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/TypedObject.java @@ -0,0 +1,81 @@ +/* +* 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.utils; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import com.google.genai.gaos.utils.Utils.JsonShape; + +@JsonSerialize(using = TypedObject.Serializer.class) +@SuppressWarnings("all") +public class TypedObject { + + private final Object value; + private final TypeReference typeReference; + private final JsonShape shape; + + private TypedObject(Object value, JsonShape shape, TypeReference typeReference) { + this.value = value; + this.shape = shape; + this.typeReference = typeReference; + } + + public Object value() { + return value; + } + + public TypeReference typeReference() { + return typeReference; + } + + public JsonShape shape() { + return shape; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypedObject of(T value, JsonShape shape, TypeReference typeReference) { + return new TypedObject(value, shape, typeReference); + } + + public static final class Serializer extends StdSerializer { + + private static final long serialVersionUID = -1; + + public Serializer() { + super(TypedObject.class); + } + + @Override + public void serialize(TypedObject value, JsonGenerator gen, SerializerProvider provider) throws IOException { + Object o = Utils.convertToShape(value.value(),value.shape(), value.typeReference()); + provider.defaultSerializeValue(o, gen); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Types.java b/src/main/java/com/google/genai/gaos/utils/Types.java new file mode 100644 index 00000000000..34b0dc667c5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Types.java @@ -0,0 +1,68 @@ +/* +* 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.utils; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +@SuppressWarnings("all") +public enum Types { + PRIMITIVE, + ARRAY, + MAP, + OBJECT, + ENUM; + + private static final Set> PRIMITIVE_TYPES = getPrimitiveWrapperTypes(); + + public static Types getType(Class clazz) { + if (clazz.isArray() || List.class.isAssignableFrom(clazz)) { + return Types.ARRAY; + } else if (Map.class.isAssignableFrom(clazz)) { + return Types.MAP; + } else if (clazz.isEnum()) { + return Types.ENUM; + } else if (isPrimitiveWrapperTypes(clazz) || clazz.isPrimitive() || String.class.isAssignableFrom(clazz)) { + return Types.PRIMITIVE; + } else { + return Types.OBJECT; + } + } + + private static boolean isPrimitiveWrapperTypes(Class clazz) { + return PRIMITIVE_TYPES.contains(clazz); + } + + private static Set> getPrimitiveWrapperTypes() { + Set> ret = new HashSet>(); + ret.add(Boolean.class); + ret.add(Character.class); + ret.add(Byte.class); + ret.add(Short.class); + ret.add(Integer.class); + ret.add(Long.class); + ret.add(Float.class); + ret.add(Double.class); + ret.add(Void.class); + return ret; + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/UnknownType.java b/src/main/java/com/google/genai/gaos/utils/UnknownType.java new file mode 100644 index 00000000000..bc050399a56 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/UnknownType.java @@ -0,0 +1,84 @@ +/* +* 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.utils; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.databind.JsonNode; +import java.util.Optional; + +/** + * Generic unknown wrapper for handling polymorphic types that don't have specific implementations. + * Preserves the raw JSON data and extracts the discriminator value. + */ +@SuppressWarnings("all") +public class UnknownType { + @JsonValue + private final JsonNode raw; + + @JsonCreator + public UnknownType(JsonNode rawNode) { + this.raw = rawNode; + } + + /** + * Extract the discriminator value from the JSON node. + * + * @param key the discriminator property name + * @return the discriminator value if present + */ + protected Optional extractDiscriminator(String key) { + return Optional.ofNullable(raw) + .filter(n -> n.has(key)) + .filter(n -> n.get(key).isTextual()) + .map(n -> n.get(key).asText()); + } + + /** + * Get the raw JSON data for this unknown type. + * + * @return the raw JSON node + */ + public JsonNode asJson() { + return raw; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnknownType other = (UnknownType) o; + return Utils.enhancedDeepEquals(this.raw, other.raw); + } + + @Override + public int hashCode() { + return Utils.enhancedHash(raw); + } + + @Override + public String toString() { + return getClass().getSimpleName() + " " + raw; + } +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/Utf8UrlEncoder.java b/src/main/java/com/google/genai/gaos/utils/Utf8UrlEncoder.java new file mode 100644 index 00000000000..b5f2e716e97 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Utf8UrlEncoder.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.utils; + +import java.io.CharArrayWriter; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.BitSet; +import java.util.Objects; + +// Internal use only +// TODO move to an internal package +@SuppressWarnings("all") +public final class Utf8UrlEncoder { + + private static final BitSet DO_NOT_ENCODE_CHARS = createDoNotEncodeChars(); + private static final int CASE_DIFF = ('a' - 'A'); + + private final BitSet safeChars; + + public static final Utf8UrlEncoder ALLOW_RESERVED = new Utf8UrlEncoder(":/?#[]@!$&'()*+,;="); + public static final Utf8UrlEncoder DEFAULT = new Utf8UrlEncoder(""); + + public static Utf8UrlEncoder allowReserved(boolean allowReserved) { + return allowReserved ? ALLOW_RESERVED : DEFAULT; + } + + private Utf8UrlEncoder(String safeCharacters) { + Objects.requireNonNull(safeCharacters, "safeCharacters"); + int max = -1; + for (int i = 0; i < safeCharacters.length(); i++) { + char ch = safeCharacters.charAt(i); + max = Math.max(ch, max); + } + BitSet safeChars = new BitSet(max + 1); + for (int i = 0; i < safeCharacters.length(); i++) { + char ch = safeCharacters.charAt(i); + safeChars.set(ch); + } + this.safeChars = safeChars; + } + + public String encode(String s) { + return encode(s, StandardCharsets.UTF_8); + } + + private String encode(String s, Charset charset) { + boolean changed = false; + StringBuilder out = new StringBuilder(s.length()); + CharArrayWriter writer = new CharArrayWriter(); + + for (int i = 0; i < s.length();) { + int c = (int) s.charAt(i); + if (DO_NOT_ENCODE_CHARS.get(c) || safeChars.get(c)) { + out.append((char) c); + i++; + } else { + // convert to external encoding before hex conversion + do { + writer.write(c); + if (c >= 0xD800 && c <= 0xDBFF) { + if ((i + 1) < s.length()) { + int d = (int) s.charAt(i + 1); + if (d >= 0xDC00 && d <= 0xDFFF) { + writer.write(d); + i++; + } + } + } + i++; + } while (i < s.length() && !DO_NOT_ENCODE_CHARS.get((c = (int) s.charAt(i)))); + + writer.flush(); + String str = new String(writer.toCharArray()); + byte[] ba = str.getBytes(charset); + for (int j = 0; j < ba.length; j++) { + out.append('%'); + char ch = Character.forDigit((ba[j] >> 4) & 0xF, 16); + // converting to use uppercase letter as part of + // the hex value if ch is a letter. + if (Character.isLetter(ch)) { + ch -= CASE_DIFF; + } + out.append(ch); + ch = Character.forDigit(ba[j] & 0xF, 16); + if (Character.isLetter(ch)) { + ch -= CASE_DIFF; + } + out.append(ch); + } + writer.reset(); + changed = true; + } + } + + return (changed ? out.toString() : s); + } + + private static BitSet createDoNotEncodeChars() { + BitSet b = new BitSet(256); + for (int i = 'a'; i <= 'z'; i++) { + b.set(i); + } + for (int i = 'A'; i <= 'Z'; i++) { + b.set(i); + } + for (int i = '0'; i <= '9'; i++) { + b.set(i); + } + b.set('-'); + b.set('_'); + b.set('.'); + b.set('*'); + return b; + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/Utils.java b/src/main/java/com/google/genai/gaos/utils/Utils.java new file mode 100644 index 00000000000..5c6f3a29521 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/Utils.java @@ -0,0 +1,1634 @@ +/* +* 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.utils; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient.Version; +import java.net.http.HttpHeaders; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.lang.Iterable; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Optional; +import java.util.Random; +import java.util.concurrent.Callable; +import java.util.function.BiPredicate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import java.util.concurrent.CompletableFuture; + +import javax.net.ssl.SSLSession; + +import org.apache.commons.io.IOUtils; + + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.IntNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; +import com.fasterxml.jackson.databind.type.TypeFactory; + +import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.AsyncSDKException; + + +@SuppressWarnings("all") +public final class Utils { + + private Utils() { + // prevent instantiation + } + + // this method exists because primitive comparisons with objects can + // give compile errors. By calling this method we force autobox to object + // version of primitive + public static boolean referenceEquals(Object a, Object b) { + return a == b; + } + + public static String generateURL(String baseURL, String path) + throws IllegalArgumentException { + if (baseURL != null && baseURL.endsWith("/")) { + baseURL = baseURL.substring(0, baseURL.length() - 1); + } + + return baseURL + path; + } + + + + public static String generateURL(Class type, String baseURL, String path, Optional params, + Globals globals) throws JsonProcessingException, IllegalArgumentException, IllegalAccessException { + if (params.isPresent()) { + return generateURL(type, baseURL, path, params.get(), globals); + } else { + return baseURL; + } + } + + public static String generateURL(Class type, String baseURL, String path, T params, + Globals globals) + throws IllegalArgumentException, IllegalAccessException, JsonProcessingException { + if (baseURL != null && baseURL.endsWith("/")) { + baseURL = baseURL.substring(0, baseURL.length() - 1); + } + + Map pathParams = new HashMap<>(); + + Field[] fields = type.getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + PathParamsMetadata pathParamsMetadata = PathParamsMetadata.parse(field); + if (pathParamsMetadata == null) { + continue; + } + + Object value = params != null ? field.get(params) : null; + value = resolveOptionals(value); + value = populateGlobal(value, field.getName(), "pathParam", globals); + if (value == null) { + continue; + } + + if (pathParamsMetadata.serialization != null && !pathParamsMetadata.serialization.isBlank()) { + Map serialized = parseSerializedParams(pathParamsMetadata, value); + pathParams.putAll(serialized); + } else { + switch (pathParamsMetadata.style) { + case "simple": + switch (Types.getType(value.getClass())) { + case ARRAY: + final List array = toList(value); + if (array.isEmpty()) { + continue; + } + + pathParams.put(pathParamsMetadata.name, + String.join(",", + array.stream() + .map(v -> valToString(v)) + .map(v -> pathEncode(v, pathParamsMetadata.allowReserved)) + .collect(Collectors.toList()))); + break; + case MAP: + Map map = (Map) value; + if (map.size() == 0) { + continue; + } + + pathParams.put(pathParamsMetadata.name, + String.join(",", map.entrySet().stream().map(e -> { + if (pathParamsMetadata.explode) { + return String.format("%s=%s", pathEncode(valToString(e.getKey()), false), + pathEncode(valToString(e.getValue()), false)); + } else { + return String.format("%s,%s", pathEncode(valToString(e.getKey()), false), + pathEncode(valToString(e.getValue()), false)); + } + }).collect(Collectors.toList()))); + break; + case OBJECT: + if (!allowIntrospection(value.getClass())) { + pathParams.put(pathParamsMetadata.name, pathEncode(valToString(value), pathParamsMetadata.allowReserved)); + break; + } + Optional unwrappedEnumValue = Reflections.getUnwrappedEnumValue(value.getClass(), value); + if (unwrappedEnumValue.isPresent()) { + pathParams.put(pathParamsMetadata.name, pathEncode( + valToString(unwrappedEnumValue.get()), + pathParamsMetadata.allowReserved)); + break; + } + List values = new ArrayList<>(); + + Field[] valueFields = value.getClass().getDeclaredFields(); + for (Field valueField : valueFields) { + valueField.setAccessible(true); + PathParamsMetadata valuePathParamsMetadata = PathParamsMetadata.parse(valueField); + if (valuePathParamsMetadata == null) { + continue; + } + + Object val = valueField.get(value); + val = resolveOptionals(val); + if (val == null) { + continue; + } + + if (pathParamsMetadata.explode) { + values.add(String.format("%s=%s", valuePathParamsMetadata.name, + pathEncode(valToString(val), valuePathParamsMetadata.allowReserved))); + } else { + values.add(String.format("%s,%s", valuePathParamsMetadata.name, + pathEncode(valToString(val), valuePathParamsMetadata.allowReserved))); + } + } + + pathParams.put(pathParamsMetadata.name, String.join(",", values)); + break; + default: + pathParams.put(pathParamsMetadata.name, pathEncode(valToString(value), pathParamsMetadata.allowReserved)); + break; + } + } + } + } + // include all global params in pathParams if not already present + if (globals != null) { + globals.pathParamsAsStream() + .filter(entry -> !pathParams.containsKey(entry.getKey())) + .forEach(entry -> pathParams.put(entry.getKey(), // + pathEncode(entry.getValue(), false))); + } + + return baseURL + templateUrl(path, pathParams); + } + + private static String pathEncode(String s, boolean allowReserved) { + return Utf8UrlEncoder.allowReserved(allowReserved).encode(s); + } + + public static boolean contentTypeMatches(String contentType, String pattern) { + if (contentType == null || contentType.isBlank()) { + return false; + } + + if (contentType.equals(pattern) || pattern.equals("*") || pattern.equals("*/*")) { + return true; + } + + String[] contentTypeParts = contentType.split(";"); + if (contentTypeParts.length == 0) { + return false; + } + String mediaType = contentTypeParts[0]; + + if (mediaType.equals(pattern)) { + return true; + } + + String[] mediaTypeParts = mediaType.split("/"); + if (mediaTypeParts.length == 2) { + if (String.format("%s/*", mediaTypeParts[0]).equals(pattern) + || String.format("*/%s", mediaTypeParts[1]).equals(pattern)) { + return true; + } + } + + return false; + } + + public static boolean allowIntrospection(Class cls) { + return !cls.equals(BigInteger.class) + && !cls.equals(BigDecimal.class) + && !cls.equals(BigIntegerString.class) + && !cls.equals(BigDecimalString.class) + && !cls.equals(LocalDate.class) + && !cls.equals(OffsetDateTime.class); + } + + public enum JsonShape { + STRING, DEFAULT; + } + + public static SerializedBody serializeRequestBody(Object request, String requestField, String serializationMethod, boolean nullable) + throws NoSuchFieldException, + IllegalArgumentException, IllegalAccessException, UnsupportedOperationException, IOException { + return RequestBody.serialize(request, requestField, serializationMethod, nullable); + } + + public static List getQueryParams(Class type, Optional params, + Globals globals) throws Exception { + if (params.isEmpty()) { + return Collections.emptyList(); + } else { + return getQueryParams(type, params.get(), globals); + } + } + + + + public static List getQueryParams(Class type, T params, + Globals globals) throws Exception { + return QueryParameters.parseQueryParams(type, params, globals); + } + + public static HTTPRequest configureSecurity(HTTPRequest request, Object security, String... allowedFields) throws Exception { + return Security.configureSecurity(request, security, allowedFields); + } + + private static final String DOLLAR_MARKER = "D9qPtyhOYzkHGu3c"; + + public static String templateUrl(String url, Map params) { + StringBuilder sb = new StringBuilder(); + + Pattern p = Pattern.compile("(\\{.*?\\})"); + Matcher m = p.matcher(url); + + while (m.find()) { + String match = m.group(1); + String key = match.substring(1, match.length() - 1); + String value = params.get(key); + if (value != null) { + // note that we replace $ characters in values with a marker + // and then replace the markers at the end with the $ characters + // because the presence of dollar signs can stuff up the next + // regex find + m.appendReplacement(sb, value.replace("$", DOLLAR_MARKER)); + } + } + m.appendTail(sb); + + return sb.toString().replace(DOLLAR_MARKER, "$"); + } + + public static Map> getHeadersFromMetadata(Object headers, Globals globals) throws Exception { + Map> result = new HashMap<>(); + if (headers == null) { + // include all global headers in result if not already present + mergeGlobalHeaders(result, globals); + + return result; + } + + Field[] fields = headers.getClass().getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + HeaderMetadata headerMetadata = HeaderMetadata.parse(field); + if (headerMetadata == null) { + continue; + } + + Object value = field.get(headers); + value = resolveOptionals(value); + value = populateGlobal(value, field.getName(), "header", globals); + + if (value == null) { + continue; + } + + switch (Types.getType(value.getClass())) { + case OBJECT: { + if (!allowIntrospection(value.getClass())) { + break; + } + Optional unwrappedEnumValue = Reflections.getUnwrappedEnumValue(value.getClass(), value); + if (unwrappedEnumValue.isPresent()) { + upsertHeader(result, headerMetadata.name, unwrappedEnumValue.get()); + break; + } + + List items = new ArrayList<>(); + Field[] valueFields = value.getClass().getDeclaredFields(); + for (Field valueField : valueFields) { + valueField.setAccessible(true); + HeaderMetadata valueHeaderMetadata = HeaderMetadata.parse(valueField); + if (valueHeaderMetadata == null || valueHeaderMetadata.name == null + || valueHeaderMetadata.name.isBlank()) { + continue; + } + + Object valueFieldValue = valueField.get(value); + valueFieldValue = resolveOptionals(valueFieldValue); + if (valueFieldValue == null) { + continue; + } + + if (headerMetadata.explode) { + items.add( + String.format("%s=%s", valueHeaderMetadata.name, + valToString(valueFieldValue))); + } else { + items.add(valueHeaderMetadata.name); + items.add(valToString(valueFieldValue)); + } + } + + if (!result.containsKey(headerMetadata.name)) { + result.put(headerMetadata.name, new ArrayList<>()); + } + + List values = result.get(headerMetadata.name); + values.add(String.join(",", items)); + + break; + } + case MAP: { + Map map = (Map) value; + if (map.size() == 0) { + continue; + } + + List items = new ArrayList<>(); + + for (Map.Entry entry : map.entrySet()) { + if (headerMetadata.explode) { + items.add(String.format("%s=%s", valToString(entry.getKey()), + valToString(entry.getValue()))); + } else { + items.add(valToString(entry.getKey())); + items.add(valToString(entry.getValue())); + } + } + + if (!result.containsKey(headerMetadata.name)) { + result.put(headerMetadata.name, new ArrayList<>()); + } + + List values = result.get(headerMetadata.name); + values.add(String.join(",", items)); + + break; + } + case ARRAY: { + final List array = toList(value); + + if (array.isEmpty()) { + continue; + } + + List items = new ArrayList<>(); + + for (Object item : array) { + items.add(valToString(item)); + } + + if (!result.containsKey(headerMetadata.name)) { + result.put(headerMetadata.name, new ArrayList<>()); + } + + List values = result.get(headerMetadata.name); + values.add(String.join(",", items)); + + break; + } + default: { + upsertHeader(result, headerMetadata.name, value); + break; + } + } + } + + // include all global headers in result if not already present + mergeGlobalHeaders(result, globals); + + return result; + } + + private static void upsertHeader(Map> headers, String key, Object val) { + headers.computeIfAbsent(key, k -> new ArrayList<>()) + .add(valToString(val)); + } + + private static void mergeGlobalHeaders(Map> headers, Globals globals) { + if (globals == null) { + return; + } + globals.headerParamsAsStream() + .filter(entry -> !headers.containsKey(entry.getKey())) + .forEach(entry -> headers.put(entry.getKey(), + Collections.singletonList(entry.getValue()))); + } + + public static String valToString(Object value) { + if (value.getClass().isEnum()) { + try { + Field field = value.getClass().getDeclaredField("value"); + field.setAccessible(true); + return String.valueOf(field.get(value)); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { + return "ERROR_UNKNOWN_VALUE"; + } + } else if (Reflections.isEnumWrapper(value)) { + // Extract the underlying value from enum wrapper + Optional unwrappedEnumValue = Reflections.getUnwrappedEnumValue(value.getClass(), value); + if (unwrappedEnumValue.isPresent()) { + return String.valueOf(unwrappedEnumValue.get()); + } else { + return "ERROR_UNKNOWN_VALUE"; + } + } else { + return String.valueOf(resolveOptionals(value)); + } + } + + public static String prefixBearer(String authHeaderValue) { + if (authHeaderValue.toLowerCase().startsWith("bearer ")) { + return authHeaderValue; + } + return "Bearer " + authHeaderValue; + } + + public static Object populateGlobal(Object value, String fieldName, String paramType, + Globals globals) { + if (value == null && globals != null) { + return globals.getParam(paramType, fieldName).orElse(null); + } + return value; + } + + private static Map parseSerializedParams(PathParamsMetadata pathParamsMetadata, Object value) + throws JsonProcessingException { + Map params = new HashMap<>(); + switch (pathParamsMetadata.serialization) { + case "json": + ObjectMapper mapper = JSON.getMapper(); + String json = mapper.writeValueAsString(value); + params.put(pathParamsMetadata.name, pathEncode(json, pathParamsMetadata.allowReserved)); + break; + default: + break; + } + return params; + } + + public static T checkNotNull(T object, String name) { + if (object == null) { + // IAE better than NPE in this use-case (NPE can suggest internal troubles) + throw new IllegalArgumentException(name + " cannot be null"); + } + return object; + } + + public static void checkArgument(boolean expression, String message) { + if (!expression) { + throw new IllegalArgumentException(message); + } + } + + public static Map emptyMapIfNull(Map map) { + return map == null ? java.util.Collections.emptyMap() : map; + } + + public static String toString(Class cls, Object... items) { + if (items.length % 2 != 0) { + throw new IllegalArgumentException("items must have an even length"); + } + StringBuilder s = new StringBuilder(); + int i = 0; + while (i < items.length) { + if (i > 0) { + s.append(", "); + } + s.append(items[i]); + s.append("="); + s.append(items[i + 1]); + i += 2; + } + return cls.getSimpleName() + "[" + s + "]"; + } + + public static Object resolveOptionals(Object o) { + if (o instanceof Optional) { + return ((Optional) o).orElse(null); + } else { + return o; + } + } + + public static List toList(Object o) { + if (o == null) { + return null; + } else if (o instanceof List) { + return (List) o; + } else if (o.getClass().isArray()) { + return Arrays.asList((Object[]) o); + } else { + throw new IllegalArgumentException("argument must be List or array"); + } + } + + public static T readDefaultOrConstValue(String name, String json, TypeReference typeReference) { + try { + return readValue(json, typeReference); + } catch (JsonProcessingException e) { + throw new IllegalArgumentException("default/const value did not match the expected type, name=" + name + ",json=\n" + json, e); + } + } + + private static T readValue(String json, TypeReference typeReference) throws JsonProcessingException { + return JSON.getMapper().readValue(json, typeReference); + } + + public static byte[] extractByteArrayFromBody(HttpResponse response) throws IOException { + return toByteArrayAndClose(response.body()); + } + + public static byte[] toByteArrayAndClose(InputStream in) throws IOException { + try { + return IOUtils.toByteArray(in); + } finally { + in.close(); + } + } + + public static String toUtf8AndClose(InputStream in) throws IOException { + return new String(toByteArrayAndClose(in), StandardCharsets.UTF_8); + } + + public static Object convertToShape(Object o, JsonShape shape, TypeReference typeReference) { + if (shape == JsonShape.STRING) { + return convertToStringShape(o, typeReference); + } else { + return o; + } + } + + private static final Map, java.util.function.Function> STRING_CONVERSIONS = Map.of(// + BigInteger.class, o -> new BigIntegerString((BigInteger) o), // + BigDecimal.class, o -> new BigDecimalString((BigDecimal) o)); + + private static final Map, java.util.function.Function> STRING_INVERSE_CONVERSIONS = Map.of(// + BigIntegerString.class, o -> ((BigIntegerString) o).value(), // + BigDecimalString.class, o -> ((BigDecimalString) o).value()); + + + private static Object convertToStringShape(Object o, TypeReference typeReference) { + JavaType jt = JSON + .getMapper() + .getTypeFactory() + .resolveMemberType(typeReference.getType(), null); + return convertToStringShape(o, jt); + } + + private static Object convertToStringShape(Object o, JavaType jt) { + if (jt.getRawClass().equals(List.class)) { + List list = (List) o; + return list.stream() // + .map(x -> convertToStringShape(x, jt.getContentType())) // + .collect(Collectors.toList()); + } else if (jt.getRawClass().equals(Map.class)) { + Map map = (Map) o; + Map result = new HashMap<>(); + for (Entry entry : map.entrySet()) { + result.put(entry.getKey(), convertToStringShape(entry.getValue(), jt.getContentType())); + } + return result; + } else if (jt.getRawClass().equals(Optional.class)) { + Optional optional = (Optional) o; + if (optional.isPresent()) { + return Optional.of(convertToStringShape(optional.get(), jt.getContentType())); + } else { + return o; + } + + } else if (STRING_CONVERSIONS.containsKey(jt.getRawClass())) { + return STRING_CONVERSIONS.get(jt.getRawClass()).apply(o); + } else { + return o; + } + } + + private static Object convertToStringShapeInverse(Object o, JavaType jt) { + if (jt.getRawClass().equals(List.class)) { + List list = (List) o; + return list.stream() // + .map(x -> convertToStringShapeInverse(x, jt.getContentType())) // + .collect(Collectors.toList()); + } else if (jt.getRawClass().equals(Map.class)) { + Map map = (Map) o; + Map result = new HashMap<>(); + for (Entry entry : map.entrySet()) { + result.put(entry.getKey(), convertToStringShapeInverse(entry.getValue(), jt.getContentType())); + } + return result; + } else if (jt.getRawClass().equals(Optional.class)) { + Optional optional = (Optional) o; + if (optional.isPresent()) { + return Optional.of(convertToStringShapeInverse(optional.get(), jt.getContentType())); + } else { + return o; + } + + } else if (STRING_INVERSE_CONVERSIONS.containsKey(jt.getRawClass())) { + return STRING_INVERSE_CONVERSIONS.get(jt.getRawClass()).apply(o); + } else { + return o; + } + } + + // used for deserialization + static JavaType convertToShape(TypeFactory f, TypeReference typeReference, JsonShape shape) { + JavaType jt = f.resolveMemberType(typeReference.getType(), null); + if (shape == JsonShape.STRING) { + return convertToStringShape(f, jt); + } else { + return jt; + } + } + + static Object convertToShapeInverse(Object o, JsonShape shape, JavaType jt) { + if (shape == JsonShape.STRING) { + return convertToStringShapeInverse(o, jt); + } else { + return o; + } + } + + // VisibleForTesting + public static JavaType convertToStringShape(TypeFactory f, JavaType a) { + if (a.getRawClass().equals(List.class)) { + JavaType b = convertToStringShape(f, a.getContentType()); + return f.constructCollectionType(List.class, b); + } else if (a.getRawClass().equals(Map.class)) { + JavaType key = f.constructType(String.class); + JavaType value = convertToStringShape(f, a.getContentType()); + return f.constructMapType(Map.class, key, value); + } else if (a.getRawClass().equals(Optional.class)) { + JavaType b = convertToStringShape(f, a.getContentType()); + return f.constructParametricType(Optional.class, b); + + } else if (a.getRawClass().equals(BigInteger.class)) { + return f.constructType(BigIntegerString.class); + } else if (a.getRawClass().equals(BigDecimal.class)) { + return f.constructType(BigDecimalString.class); + } else { + return a; + } + } + + public static final class TypeReferenceWithShape { + private final TypeReference typeReference; + private final JsonShape shape; + + private TypeReferenceWithShape(TypeReference typeReference, JsonShape shape) { + this.typeReference = typeReference; + this.shape = shape; + } + + public static TypeReferenceWithShape of(TypeReference typeReference, JsonShape shape) { + return new TypeReferenceWithShape(typeReference, shape); + } + + public TypeReference typeReference() { + return typeReference; + } + + public JsonShape shape() { + return shape; + } + } + + static Object resolveStringShape(Class type, String fieldName, Object value) throws IllegalAccessException { + if (value == null) { + return value; + } + + try { + // the presence of this TypeReference field indicates that the parameter + // has a JsonShape of String and that we should convert BigInteger to + // BigIntegerString and BigDecimal to BigDecimalString + // where explicitly mentioned in the TypeReference + Field tr = type.getDeclaredField(fieldName + "_typeReference"); + tr.setAccessible(true); + TypeReference typeReference = (TypeReference) tr.get(null); + // adjust the value so BigInteger and BigDecimal serialize to string + return convertToShape(value, JsonShape.STRING, typeReference); + } catch (NoSuchFieldException e) { + return value; + } + } + + public static Stream stream(Callable> first, Function> next) { + return StreamSupport.stream(iterable(first, next).spliterator(), false); + } + + public static Stream toStream(Iterable iterable) { + return StreamSupport.stream(iterable.spliterator(), false); + } + + + // need a Function method that throws + public interface Function { + T apply(S value) throws Exception; + } + + private static Iterable iterable(Callable> first, Function> next) { + return new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + + private boolean pending = true; + + private Optional nxt; + + @Override + public boolean hasNext() { + load(); + return nxt.isPresent(); + } + + @Override + public T next() { + load(); + if (!nxt.isPresent()) { + throw new NoSuchElementException(); + } else { + pending = true; + return nxt.get(); + } + } + + private void load() { + try { + if (pending) { + if (nxt == null) { + nxt = first.call(); + } else if (nxt.isPresent()) { + nxt = next.apply(nxt.get()); + } + pending = false; + } + } catch (Exception e) { + Exceptions.rethrow(e); + } + } + }; + } + }; + } + + public static boolean statusCodeMatches(int statusCode, String... expectedStatusCodes) { + return Arrays.stream(expectedStatusCodes) + .anyMatch(expected -> statusCodeMatchesOne(statusCode, expected)); + } + + // VisibleForTesting + public static boolean statusCodeMatchesOne(int statusCode, String expectedStatusCode) { + checkNotNull(expectedStatusCode, "expectedStatusCode"); + if (expectedStatusCode.toLowerCase(Locale.ENGLISH).equals("default")) { + return true; + } + if (statusCode < 100 || statusCode >= 600) { + throw new IllegalArgumentException("unexpected http status code: " + statusCode); + } + if (expectedStatusCode.length() != 3) { + return false; + } + String firstDigit = String.valueOf(statusCode / 100); + String firstDigitExpected = expectedStatusCode.substring(0, 1); + if (!firstDigit.equals(firstDigitExpected)) { + return false; + } else if (expectedStatusCode.toUpperCase(Locale.ENGLISH).endsWith("XX")) { + return true; + } else { + return expectedStatusCode.equals(String.valueOf(statusCode)); + } + } + + /** + * Returns an {@link HttpRequest.Builder} which is initialized with the + * state of the given {@link HttpRequest}. + * + * @param request request to copy + * @return a builder initialized with values from {@code request} + */ + public static HttpRequest.Builder copy(HttpRequest request) { + return copy(request, (k, v) -> true); + } + + /** + * Returns an {@link HttpRequest.Builder} which is initialized with the + * state of the given {@link HttpRequest}. + * + * @param request request to copy + * @param filter selects which header key-values to include in the copied request + * @return a builder initialized with values from {@code request} + */ + public static HttpRequest.Builder copy(HttpRequest request, BiPredicate filter) { + // in JDK 16+ we can use this + // return HttpRequest.newBuilder(request, (k, v) -> true); + checkNotNull(request, "request"); + + final HttpRequest.Builder builder = HttpRequest.newBuilder(); + builder.uri(request.uri()); + builder.expectContinue(request.expectContinue()); + + request.headers() + .map() + .forEach((name, values) -> + values.stream() + .filter(v -> filter.test(name, v)) + .forEach(value -> builder.header(name, value))); + + request.version().ifPresent(builder::version); + request.timeout().ifPresent(builder::timeout); + var method = request.method(); + request.bodyPublisher().ifPresentOrElse( + // if body is present, set it + bodyPublisher -> builder.method(method, bodyPublisher), + // otherwise, the body is absent, special case for GET/DELETE, + // or else use empty body + () -> { + switch (method) { + case "GET": builder.GET();break; + case "DELETE" : builder.DELETE();break; + default : builder.method(method, HttpRequest.BodyPublishers.noBody()); + } + } + ); + return builder; + } + + // convenience method so that classes don't need to import a possibly colliding name of JSON + // (Utils is a very common import) + public static ObjectMapper mapper() { + return JSON.getMapper(); + } + + public static T asType(EventStreamMessage x, ObjectMapper mapper, TypeReference typeReference) { + try { + try { + String json = json(x, mapper, false); + return mapper.readValue(json, typeReference); + } catch (JsonProcessingException e) { + // retry with the assumption that data field is plain text + String json = json(x, mapper, true); + return mapper.readValue(json, typeReference); + } + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + public static String json(EventStreamMessage m, ObjectMapper mapper, boolean dataIsPlainText) + throws JsonProcessingException { + ObjectNode node = mapper.createObjectNode(); + m.event().ifPresent(value -> node.set("event", new TextNode(value))); + m.id().ifPresent(value -> node.set("id", new TextNode(value))); + m.retryMs().ifPresent(value -> node.set("retry", new IntNode(value))); + m.data().ifPresent(data -> { + if (dataIsPlainText) { + node.set("data", new TextNode(data)); + } else { + try { + JsonNode tree = mapper.readTree(data); + node.set("data", tree); + } catch (JsonProcessingException e) { + node.set("data", new TextNode(data)); + } + } + }); + return mapper.writeValueAsString(node); + } + + /** + * Fully reads the body of the given response and caches it in memory. The + * returned response has utility methods to view the body + * ({@code bodyAsUtf8(), bodyAsBytes()} and the {@code body()} method can be + * called multiple times, each returning a fresh {@link InputStream} that will + * read from the cached byte array. + * + *

+ * This method is most likely to be used in a diagnostic/logging situtation so + * that the contents of a response can be viewed without affecting processing. + * Using this method with a very large body may be problematic in + * terms of memory use. + * + * @param response response to cache + * @return response with a cached body + * @throws IOException + */ + public static HttpResponseCached cache(HttpResponse response) throws IOException { + return new HttpResponseCached(response); + } + + public static final class HttpResponseCached implements HttpResponse { + + private final HttpResponse response; + private final byte[] bytes; + + public HttpResponseCached(HttpResponse response) throws IOException { + this.response = response; + this.bytes = toByteArrayAndClose(response.body()); + } + + public String bodyAsUtf8() { + return new String(bytes, StandardCharsets.UTF_8); + } + + public byte[] bodyAsBytes() { + return bytes; + } + + @Override + public int statusCode() { + return response.statusCode(); + } + + @Override + public HttpRequest request() { + return response.request(); + } + + @Override + public Optional> previousResponse() { + return response.previousResponse(); + } + + @Override + public HttpHeaders headers() { + return response.headers(); + } + + @Override + public InputStream body() { + return new ByteArrayInputStream(bytes); + } + + @Override + public Optional sslSession() { + return response.sslSession(); + } + + @Override + public URI uri() { + return response.uri(); + } + + @Override + public Version version() { + return response.version(); + } + + @Override + public String toString() { + return response.toString(); + } + } + + private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); + + public static byte[] readBytes(String filename) { + return readBytes(new File(filename)); + } + + public static String readString(String filename) { + return readString(new File(filename)); + } + + public static byte[] readBytes(File file) { + try { + return readBytesAndClose(new FileInputStream(file)); + } catch (FileNotFoundException e) { + throw new UncheckedIOException(e); + } + } + + public static String readString(File file) { + byte[] bytes = readBytes(file); + return new String(bytes, StandardCharsets.UTF_8); + } + + public static byte[] readBytesAndClose(InputStream in) { + try { + return readBytes(in); + } finally { + try { + in.close(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + } + + public static byte[] readBytes(InputStream in) { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + byte[] buffer = new byte[8192]; + int n; + try { + while ((n = in.read(buffer))!= -1) { + bytes.write(buffer, 0, n); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + return bytes.toByteArray(); + } + + public static String toHex(byte[] bytes) { + return toHex(bytes, bytes.length); + } + + private static String toHex(byte[] bytes, int length) { + char[] hexChars = new char[length * 2]; + for (int j = 0; j < length; j++) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = HEX_ARRAY[v >>> 4]; + hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; + } + return new String(hexChars); + } + + @SuppressWarnings("unchecked") + public static String discriminatorToString(Object o) { + // expects o to be either an Optional, Enum (with a String value() method), + // an open enum wrapper, or a String value + Class cls = o.getClass(); + if (cls.equals(Optional.class)) { + Optional a = (Optional) o; + return a.map(x -> discriminatorToString(x)).orElse(null); + } + + // Check if it's an open enum wrapper + if (Reflections.isEnumWrapper(o)) { + Optional value = Reflections.getUnwrappedEnumValue(cls, o); + return value.map(String::valueOf).orElse(null); + } + + // Handle regular enums + if (cls.isEnum()) { + try { + Method m = cls.getMethod("value"); + return (String) m.invoke(o); + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + // Fall back to String cast + return (String) o; + } + + public static void recordTest(String id) { + try { + new File("build").mkdir(); + Files.writeString(Paths.get("build/test-javav2-record.txt"), id + "\n", StandardOpenOption.CREATE, + StandardOpenOption.APPEND); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + /** + * Returns an equivalent url with query parameters sorted by name. Sort is + * stable in that parameters with the same name will not be reordered. + * + * @param url input + * @return url with query parameters sorted by name + */ + public static String sortQueryParameters(String url) { + if (url == null || url.isBlank()) { + return ""; + } + String[] parts = url.split("\\?"); + if (parts.length == 1) { + return url; + } + String query = parts[1]; + String[] params = query.split("&"); + sortByDelimitedKey(params, "="); + return parts[0] + "?" + Arrays.stream(params).collect(Collectors.joining("&")); + } + + public static Object sortSerializedMaps(Object input, String regex, String delim) { + if (input == null) { + return input; + } else if (input instanceof String) { + return sortMapString((String) input, regex, delim); + } else if (input.getClass().isArray()) { + Object[] a = (Object[]) input; + String[] b = new String[a.length]; + for (int i = 0; i < a.length; i++) { + if (!(a[i] instanceof String)) { + throw new IllegalArgumentException("expected array item type of String, found " + a[i]); + } + b[i] = sortMapString((String) a[i], regex, delim); + } + return b; + } else if (input instanceof Map) { + @SuppressWarnings("unchecked") + Map a = (Map) input; + Map b = new LinkedHashMap<>(); + for (Entry entry: a.entrySet()) { + if (!(entry.getKey() instanceof String)) { + throw new IllegalArgumentException("expected map key type of String, found " + entry.getKey()); + } + if (!(entry.getValue() instanceof String)) { + throw new IllegalArgumentException("expected map value type of String, found " + entry.getValue()); + } + b.put((String) entry.getKey(), sortMapString((String) entry.getValue(), regex, delim)); + } + return b; + } else { + throw new IllegalArgumentException("unexpected type: " + input.getClass()); + } + } + + private static String sortMapString(String input, String regex, String delim) { + return Pattern.compile(regex).matcher(input).replaceAll(m -> { + String escapedDelim = Pattern.quote(delim); + String result = m.group(); + for (int i = 1; i <= m.groupCount(); i++) { + final String match = m.group(i); + String[] pairs; + if (match.contains("=")) { + pairs = match.split(escapedDelim); + sortByDelimitedKey(pairs, "="); + } else { + String[] values = match.split(escapedDelim); + if (values.length == 1) { + pairs = values; + } else { + pairs = new String[values.length / 2]; + for (int j = 0; j < values.length; j += 2) { + pairs[j / 2] = values[j] + delim + values[j + 1]; + } + } + sortByDelimitedKey(pairs, delim); + } + String joined = Arrays.stream(pairs).collect(Collectors.joining(delim)); + result = result.replace(m.group(i), joined); + } + return result; + }); + } + + private static void sortByDelimitedKey(String[] array, String delim) { + Arrays.sort(array, (a, b) -> { + String escapedDelim = Pattern.quote(delim); + String aKey = a.split(escapedDelim)[0]; + String bKey = b.split(escapedDelim)[0]; + return aKey.compareTo(bKey); + }); + } + + public static boolean isPresentAndNotNull(Optional x) { + return x.isPresent(); + } + + + + public static void setSseSentinel(Object o, String value) { + if (o == null || value.isBlank()) { + return; + } else { + try { + Field field = o.getClass().getDeclaredField("_eventSentinel"); + field.setAccessible(true); + field.set(o, Optional.of(value)); + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + // ignore + } + } + } + + public static String sessionKey(String... items) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + String input = Arrays.stream(items).collect(Collectors.joining(":")); + byte[] bytes = md.digest(input.getBytes(StandardCharsets.UTF_8)); + return Utils.toHex(bytes).toLowerCase(Locale.ENGLISH); + } catch (NoSuchAlgorithmException e) { + // not expected, MD5 always available + throw new RuntimeException(e); + } + } + + // internal API + public static HTTPClient createTestHTTPClient(String testName) { + return createTestHTTPClient(new SpeakeasyHTTPClient(), testName); + } + + // internal API + public static HTTPClient createTestHTTPClient(SpeakeasyHTTPClient client, String testName) { + return new TestHTTPClient(client, testName, randomLetters(16)); + } + + private static final class TestHTTPClient implements HTTPClient { + + private final HTTPClient client; + private final String testName; + private final String testInstanceId; + + TestHTTPClient(HTTPClient client, String testName, String testInstanceId) { + checkNotNull(client, "client"); + checkNotNull(testName, "name"); + checkNotNull(testInstanceId, "instanceId"); + this.client = client; + this.testName = testName; + this.testInstanceId = testInstanceId; + } + + @Override + public HttpResponse send(HttpRequest request) + throws IOException, InterruptedException, URISyntaxException { + HttpRequest r = Utils.copy(request) // + .header("x-speakeasy-test-name", testName) // + .header("x-speakeasy-test-instance-id", testInstanceId) // + .build(); + return client.send(r); + } + } + + private static final Random RANDOM = new Random(); + + private static String randomLetters(int length) { + return RANDOM.ints(length).mapToObj(x -> (char) (Math.abs(x) % 26 + 'a') + "").collect(Collectors.joining()); + } + + /** + * Internal use. Returns the system property with {@code key = "env." + name} + * and if doesn't exist returns the value of the environment variable with the + * given name of if it doesn't exist returns {@code defaultValue}. + * + * @param name variable name + * @param defaultValue default value if system property and environment variable + * don't exist + * @return system property with name prepended with ".env" or environment + * variable of given name or default value + */ + public static String environmentVariable(String name, String defaultValue) { + String value = System.getProperty("env." + name); + if (value != null) { + return value; + } + value = System.getenv(name); + if (value != null) { + return value; + } else { + return defaultValue; + } + } + + + // internal use + public static String sortJSONObjectKeys(String json, String... fields) { + var fieldList = List.of(fields); + var m = new ObjectMapper(); + try { + JsonNode tree = m.readTree(json); + if (!tree.isObject()) { + return json; + } else if (fieldList.isEmpty()) { + return m.writeValueAsString(sortKeys(m, tree)); + } else { + var node = (ObjectNode) tree; + var list = toList(node.fields()); + list.stream() // + .filter(entry -> fieldList.contains(entry.getKey())) // + .forEach(entry -> node.set(entry.getKey(), sortKeys(m, entry.getValue()))); + return m.writeValueAsString(node); + } + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + private static JsonNode sortKeys(ObjectMapper m, JsonNode node) { + if (!node.isObject()) { + return node; + } else { + var list = toList(node.fields()); + list.sort((a, b) -> a.getKey().compareTo(b.getKey())); + var map = new LinkedHashMap(); + list.forEach(x -> map.put(x.getKey(), x.getValue())); + return new ObjectNode(m.getNodeFactory(), map); + } + } + + private static List toList(Iterator it) { + var list = new ArrayList(); + while (it.hasNext()) { + list.add(it.next()); + } + return list; + } + + public static T valueOrElse(T value, T valueIfNotPresent) { + return value != null ? value : valueIfNotPresent; + } + + public static T valueOrElse(Optional value, T valueIfNotPresent) { + if (value == null) { + // this defensive check is used in custom exception class constructors + // to simplify calling code + return valueIfNotPresent; + } + return value.orElse(valueIfNotPresent); + } + + + + public static T valueOrNull(T value) { + return valueOrElse(value, null); + } + + public static T valueOrNull(Optional value) { + return valueOrElse(value, null); + } + + + + public static N castLong(long value, Class targetType) { + // Handle supported types safely + if (targetType == Integer.class) { + return targetType.cast((int) value); + } else if (targetType == Long.class) { + return targetType.cast(value); + } else if (targetType == Short.class) { + return targetType.cast((short) value); + } else if (targetType == BigInteger.class) { + return targetType.cast(BigInteger.valueOf(value)); + } else { + throw new IllegalArgumentException("Unsupported number type: " + targetType); + } + } + + public static Iterator transform(Iterator iterator, Function mapper) { + return new Iterator<>() { + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public O next() { + return Exceptions.unchecked(() -> mapper.apply(iterator.next())).get(); + } + }; + } + + /** + * Returns true if and only if the two objects are deeply equal, uses + * mathematical equivalence for Number subclasses ({@code 2 == 2.0}) instead of + * {@code Number.equals}. + * + *

+ * Should be paired with {@link #enhancedHashCode(Object)} to ensure the + * equals/hashCode contract. + * + * @param a the first object to compare + * @param b the second object to compare + * @return true if the objects are deeply equal bearing in mind mathematical + * equivalence, false otherwise + */ + public static boolean enhancedDeepEquals(Object a, Object b) { + if (a == null && b == null) { + return true; + } else if (a == null || b == null) { + return false; + } else if (a instanceof Optional && b instanceof Optional) { + return enhancedDeepEquals(((Optional) a).orElse(null), ((Optional) b).orElse(null)); + + } else if (a instanceof List && b instanceof List) { + List listA = (List) a; + List listB = (List) b; + if (listA.size() != listB.size()) { + return false; + } + for (int i = 0; i < listA.size(); i++) { + if (!enhancedDeepEquals(listA.get(i), listB.get(i))) { + return false; + } + } + return true; + } else if (a instanceof Map && b instanceof Map) { + // don't expect number keys, just Strings and enums + Map x = (Map) a; + Map y = (Map) b; + if (x.size() != y.size()) { + return false; + } + for (Entry entry : x.entrySet()) { + Object key = entry.getKey(); + Object value1 = entry.getValue(); + Object value2 = y.get(key); + if (!enhancedDeepEquals(value1, value2)) { + return false; + } + } + return true; + } else if (a instanceof Number && b instanceof Number) { + // compare values mathematically + BigDecimal x = toBigDecimal((Number) a); + BigDecimal y = toBigDecimal((Number) b); + return x.compareTo(y) == 0; + } else { + // we use deepEquals so that byte[] fields are compared appropriately + return Objects.deepEquals(a, b); + } + } + + /** + * Returns a combined hash code (applying {@link #enhancedHashCode}) for the + * given objects (usually the fields of an object whose hashCode we want to + * be calculated). + * + * @param objects + * @return combined hash code for the objects, 0 if the objects are null + */ + public static int enhancedHash(Object... objects) { + if (objects == null) { + return 0; + } + int result = 1; + for (Object o : objects) { + result = 31 * result + (o == null ? 0 :enhancedHashCode(o)); + } + return result; + } + + /** + * Returns a hash code that complies with the equals/hashCode contract when + * equals is implemented by {@link #enhancedDeepEquals(Object, Object)}. + * + * @param o object to calculate the hash code for (can be null) + * @return hash code for the object, 0 if the object is null + */ + public static int enhancedHashCode(Object o) { + if (o == null) { + return 0; + } else if (o instanceof Optional) { + Optional opt = (Optional) o; + return opt.map(Utils::enhancedHashCode).orElse(Optional.empty().hashCode()); + + } else if (o instanceof List) { + return ((List) o).stream().mapToInt(Utils::enhancedHashCode).sum(); + } else if (o instanceof Map) { + // don't expect number keys, just Strings and enums + Map m = (Map) o; + return m.entrySet() // + .stream() // + .mapToInt(entry -> Objects.hashCode(entry.getKey()) + Utils.enhancedHashCode(entry.getValue())) // + .sum(); + } else if (o instanceof Number) { + return toBigDecimal((Number) o).stripTrailingZeros().hashCode(); + } else { + return o.hashCode(); + } + } + + private static BigDecimal toBigDecimal(Number number) { + if (number instanceof BigDecimal) { + return (BigDecimal) number; + } else if (number instanceof BigInteger) { + return new BigDecimal((BigInteger) number); + } else if (number instanceof Byte || number instanceof Short || + number instanceof Integer || number instanceof Long) { + return BigDecimal.valueOf(number.longValue()); + } else if (number instanceof Float || number instanceof Double) { + // Prevent precision issues for float/double + return BigDecimal.valueOf(number.doubleValue()); + } else { + // Fallback: treat as double + return BigDecimal.valueOf(number.doubleValue()); + } + } + + /** + * Creates a failed CompletableFuture with an async API exception. + * Uses the Blob to read the response body asynchronously. + */ + public static CompletableFuture createAsyncApiError( + HttpResponse response, + String reason) { + return response.body().toByteArray() + .thenApply(bodyBytes -> { + throw new AsyncSDKException( + reason, + response.statusCode(), + bodyBytes, + response, + null); + }); + } + + public static T unmarshal(HttpResponse response, TypeReference typeReference) { + try { + return mapper().readValue( + Utils.extractByteArrayFromBody(response), + typeReference); + } catch (Exception e) { + throw SDKException.from( + "Error deserializing response body: " + e.getMessage(), response, e); + } + } + public static CompletableFuture unmarshalAsync(HttpResponse response, TypeReference typeReference) { + return response.body() + .toByteArray() + .handle((bytes, err) -> { + // if a body read error occurs, we want to transform the exception + if (err != null) { + throw new AsyncSDKException( + "Error reading response body: " + err.getMessage(), + response.statusCode(), + null, + response, + err); + } + try { + return mapper().readValue(bytes, typeReference); + } catch (Exception e) { + throw new AsyncSDKException( + "Error deserializing response body: " + e.getMessage(), + response.statusCode(), + bytes, + response, + e); + } + }); + } +} diff --git a/src/main/java/com/google/genai/gaos/utils/reactive/EventStream.java b/src/main/java/com/google/genai/gaos/utils/reactive/EventStream.java new file mode 100644 index 00000000000..1eba728b266 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/reactive/EventStream.java @@ -0,0 +1,401 @@ +/* +* 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.utils.reactive; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.genai.gaos.utils.AsyncResponse; +import com.google.genai.gaos.utils.Blob; +import com.google.genai.gaos.utils.EventStreamMessage; +import com.google.genai.gaos.utils.SpeakeasyLogger; +import com.google.genai.gaos.utils.StreamingParser; +import com.google.genai.gaos.utils.Utils; + +import java.net.http.HttpResponse; +import java.nio.ByteBuffer; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Flow; +import java.util.concurrent.atomic.AtomicLong; +import org.reactivestreams.Publisher; +import org.reactivestreams.Subscriber; +import org.reactivestreams.Subscription; + +/** + * A reactive event stream publisher that can handle different protocols (SSE, JSONL) + * and emits typed events with proper backpressure handling. + * + * @param the AsyncResponse type that contains the event stream + * @param the type that events are deserialized into + */ +@SuppressWarnings("all") +public class EventStream implements Publisher { + + private static final SpeakeasyLogger logger = SpeakeasyLogger.getLogger(EventStream.class); + + /** + * Protocol interface that defines how to parse and process different event stream formats + */ + public interface Protocol { + /** + * Create a new parser instance for this protocol + */ + StreamingParser createParser(); + + /** + * Process a parsed item and convert it to the target type + * @param parsed the parsed item from the parser + * @param objectMapper the ObjectMapper for deserialization + * @param typeReference the target type reference + * @return the converted item, or null if this item should be skipped + * @throws Exception if conversion fails + */ + ItemT processItem(ParsedT parsed, ObjectMapper objectMapper, TypeReference typeReference) throws Exception; + + /** + * Check if processing should stop (e.g., terminal message encountered) + * @param parsed the parsed item + * @return true if processing should stop + */ + boolean shouldStop(ParsedT parsed); + } + + private final CompletableFuture asyncResponseFuture; + private final TypeReference typeReference; + private final ObjectMapper objectMapper; + private final Protocol protocol; + + private EventStream(CompletableFuture asyncResponseFuture, + TypeReference typeReference, + ObjectMapper objectMapper, + Protocol protocol) { + this.asyncResponseFuture = asyncResponseFuture; + this.typeReference = typeReference; + this.objectMapper = objectMapper; + this.protocol = protocol; + logger.debug("Reactive EventStream initialized for type: {}", typeReference.getType().getTypeName()); + } + + /** + * Create an EventStream for SSE (Server-Sent Events) format + */ + public static EventStream forSSE( + CompletableFuture asyncResponseFuture, + TypeReference typeReference, + ObjectMapper objectMapper, + String terminalMessage) { + return forSSE(asyncResponseFuture, typeReference, objectMapper, terminalMessage, true); + } + + public static EventStream forSSE( + CompletableFuture asyncResponseFuture, + TypeReference typeReference, + ObjectMapper objectMapper, + String terminalMessage, + boolean dataRequired) { + return new EventStream<>(asyncResponseFuture, typeReference, objectMapper, + new SSEProtocol<>(terminalMessage, dataRequired)); + } + + /** + * Create an EventStream for JSONL (JSON Lines) format + */ + public static EventStream forJsonL( + CompletableFuture asyncResponseFuture, + TypeReference typeReference, + ObjectMapper objectMapper) { + return new EventStream<>(asyncResponseFuture, typeReference, objectMapper, + new JsonLProtocol<>()); + } + + /** + * Returns the value of the Content-Type header. + **/ + public CompletableFuture contentType() { + return asyncResponseFuture.thenApply(AsyncResponse::contentType); + } + + /** + * Returns the HTTP status code. + **/ + public CompletableFuture statusCode() { + return asyncResponseFuture.thenApply(AsyncResponse::statusCode); + } + + /** + * Returns the raw HTTP response. + **/ + public CompletableFuture> rawResponse() { + return asyncResponseFuture.thenApply(AsyncResponse::rawResponse); + } + + /** + * Returns the AsyncResponse body. + **/ + public CompletableFuture body() { + return asyncResponseFuture; + } + + @Override + public void subscribe(Subscriber subscriber) { + if (subscriber == null) { + throw new NullPointerException("Subscriber cannot be null"); + } + + EventStreamSubscription subscription = new EventStreamSubscription(subscriber); + subscriber.onSubscribe(subscription); + // Start the async operation only after onSubscribe has been called + subscription.start(rawResponse()); + } + + private class EventStreamSubscription implements Subscription { + private final Subscriber subscriber; + private final AtomicLong demand = new AtomicLong(0); + private final StreamingParser parser; + + private Flow.Subscription upstreamSubscription; + private volatile boolean cancelled = false; + private volatile boolean completed = false; + + @SuppressWarnings("unchecked") + public EventStreamSubscription(Subscriber subscriber) { + this.subscriber = subscriber; + this.parser = ((Protocol) protocol).createParser(); + } + + public void start(CompletableFuture> httpResponseFuture) { + // Wait for the CompletableFuture and then subscribe to the Blob + httpResponseFuture.whenComplete((httpResponse, throwable) -> { + if (cancelled) { + return; + } + if (throwable != null) { + // Signal error immediately per Reactive Streams specification + signalError(throwable); + return; + } + + // Extract Blob from HttpResponse and subscribe to it + Blob blob = httpResponse.body(); + // Blob.asPublisher() now returns Flow.Publisher directly + Flow.Publisher flowPublisher; + try { + flowPublisher = blob.asPublisher(); + } catch (Exception e) { + // Handle case where blob is already consumed or other errors + signalError(e); + return; + } + flowPublisher.subscribe(new Flow.Subscriber<>() { + @Override + public void onSubscribe(Flow.Subscription subscription) { + if (cancelled) { + subscription.cancel(); + return; + } + upstreamSubscription = subscription; + requestMoreIfNeeded(); + } + + @Override + public void onNext(ByteBuffer byteBuffer) { + if (cancelled || completed) { + return; + } + try { + processBuffer(byteBuffer); + if (!completed) { + requestMoreIfNeeded(); + } + } catch (Exception e) { + signalError(e); + } + } + + @Override + public void onError(Throwable throwable) { + signalError(throwable); + } + + @Override + public void onComplete() { + try { + processEndOfStream(); + signalComplete(); + } catch (Exception e) { + signalError(e); + } + } + }); + }); + } + + @Override + public void request(long n) { + if (n <= 0) { + signalError(new IllegalArgumentException("Request amount must be positive")); + return; + } + if (cancelled || completed) { + return; + } + demand.addAndGet(n); + requestMoreIfNeeded(); + } + + @Override + public void cancel() { + if (!cancelled) { + cancelled = true; + if (upstreamSubscription != null) { + upstreamSubscription.cancel(); + } + } + } + + private void processBuffer(ByteBuffer byteBuffer) { + // Use ByteBuffer directly without copying + Optional parsedOpt = parser.add(byteBuffer); + while (parsedOpt.isPresent()) { + if (!processItem(parsedOpt.get())) { + return; // Stop processing (terminal condition or error) + } + // Check for additional items in the buffer + parsedOpt = parser.next(); + } + } + + @SuppressWarnings("unchecked") + private boolean processItem(Object parsed) { + Protocol typedProtocol = (Protocol) protocol; + + // Check if processing should stop + if (typedProtocol.shouldStop(parsed)) { + signalComplete(); + return false; + } + + // Emit if there's demand + if (demand.get() > 0) { + try { + ItemT item = typedProtocol.processItem(parsed, objectMapper, typeReference); + if (item != null) { + demand.decrementAndGet(); + if (logger.isTraceEnabled()) { + logger.trace("Reactive EventStream item emitted"); + } + subscriber.onNext(item); + } + } catch (Exception e) { + logger.debug("Error processing reactive EventStream item: {}", e.getMessage()); + signalError(e); + return false; // Signal to stop processing on error + } + } + return true; // Continue processing + } + + private void requestMoreIfNeeded() { + if (cancelled || completed) { + return; + } + + if (upstreamSubscription != null && demand.get() > 0) { + upstreamSubscription.request(1); + } + } + + private void processEndOfStream() { + Optional parsedOpt = parser.finish(); + parsedOpt.ifPresent(this::processItem); + } + + private void signalError(Throwable t) { + if (!cancelled && !completed) { + completed = true; + subscriber.onError(t); + } + } + + private void signalComplete() { + if (!cancelled && !completed) { + completed = true; + logger.debug("Reactive EventStream completed"); + subscriber.onComplete(); + } + } + } + + /** + * SSE Protocol implementation + */ + private static class SSEProtocol implements Protocol { + private final String terminalMessage; + private final boolean dataRequired; + + public SSEProtocol(String terminalMessage, boolean dataRequired) { + this.terminalMessage = terminalMessage; + this.dataRequired = dataRequired; + } + + @Override + public StreamingParser createParser() { + return StreamingParser.forSSE(); + } + + @Override + public ItemT processItem(EventStreamMessage message, ObjectMapper objectMapper, TypeReference typeReference) { + // Skip events without data when data is required + if (dataRequired && message.data().isEmpty()) { + return null; + } + return Utils.asType(message, objectMapper, typeReference); + } + + @Override + public boolean shouldStop(EventStreamMessage message) { + // Check if this is a terminal message + return terminalMessage != null && message.data().map(terminalMessage::equals).orElse(false); + } + } + + /** + * JSONL Protocol implementation + */ + private static class JsonLProtocol implements Protocol { + + @Override + public StreamingParser createParser() { + return StreamingParser.forJsonLines(); + } + + @Override + public ItemT processItem(String jsonLine, ObjectMapper objectMapper, TypeReference typeReference) throws Exception { + return objectMapper.readValue(jsonLine, typeReference); + } + + @Override + public boolean shouldStop(String jsonLine) { + // JSONL doesn't have terminal messages + return false; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/google/genai/gaos/utils/reactive/ReactiveUtils.java b/src/main/java/com/google/genai/gaos/utils/reactive/ReactiveUtils.java new file mode 100644 index 00000000000..1ecb978fb25 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/utils/reactive/ReactiveUtils.java @@ -0,0 +1,529 @@ +/* +* 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.utils.reactive; + +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Flow; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Function; + +// Internal API only + +/** + * Utility class for reactive stream operations. + */ +@SuppressWarnings("all") +public final class ReactiveUtils { + + private ReactiveUtils() { + // Utility class + } + + /** + * Maps elements from a Flow.Publisher using an asynchronous transformation function. + * This is useful for transforming HttpResponse elements using operations + * that return CompletableFuture results. + * + * @param the input element type + * @param the output element type + * @param source the source publisher + * @param mapper the async transformation function (e.g., AsyncOperation::handleResponse) + * @return a new publisher that emits the mapped elements + */ + public static Flow.Publisher mapAsync( + Flow.Publisher source, + Function> mapper) { + + Objects.requireNonNull(source, "Source publisher cannot be null"); + Objects.requireNonNull(mapper, "Mapper function cannot be null"); + + return new AsyncMappingPublisher<>(source, mapper); + } + + /** + * Maps elements from a Flow.Publisher using a synchronous transformation function. + * + * @param the input element type + * @param the output element type + * @param source the source publisher + * @param mapper the transformation function + * @return a new publisher that emits the mapped elements + */ + public static Flow.Publisher map( + Flow.Publisher source, + Function mapper) { + + Objects.requireNonNull(source, "Source publisher cannot be null"); + Objects.requireNonNull(mapper, "Mapper function cannot be null"); + + return new SyncMappingPublisher<>(source, mapper); + } + + /** + * Flattens a stream of collections into a stream of individual items. + * + * @param the input collection type + * @param the output element type + * @param source the source publisher emitting collections + * @param flattener the function to extract items from each collection + * @return a new publisher that emits individual items from the collections + */ + public static Flow.Publisher flatten( + Flow.Publisher source, + Function> flattener) { + + Objects.requireNonNull(source, "Source publisher cannot be null"); + Objects.requireNonNull(flattener, "Flattener function cannot be null"); + + return new FlatteningPublisher<>(source, flattener); + } + + /** + * Flattens a stream of {@code List} into a stream of individual {@code T} items. + * + * @param the type of elements to emit downstream + * @param source the source publisher emitting lists + * @return a new publisher that emits individual items from the lists + */ + public static Flow.Publisher flatten(Flow.Publisher> source) { + return flatten(source, list -> list); + } + + /** + * Wraps a {@code Flow.Publisher} into a {@code Flow.Publisher>}. + * + * @param source the source publisher + * @param the type of elements to emit downstream + * @return a new publisher that emits lists of items from the source publisher + */ + public static Flow.Publisher> wrapped(Flow.Publisher source) { + return new SyncMappingPublisher<>(source, List::of); + } + + /** + * Concatenates multiple publishers into a single publisher. + * + * @param pubs the publishers to concatenate + * @param the type of elements to emit downstream + * @return a new publisher that concatenates the given publishers + */ + public static Flow.Publisher concat(List> pubs) { + return new ConcatPublisher<>(pubs); + } + + /** + * Internal implementation of async mapping publisher. + */ + private static class AsyncMappingPublisher implements Flow.Publisher { + private final Flow.Publisher source; + private final Function> mapper; + + public AsyncMappingPublisher(Flow.Publisher source, Function> mapper) { + this.source = source; + this.mapper = mapper; + } + + @Override + public void subscribe(Flow.Subscriber subscriber) { + source.subscribe(new AsyncMappingSubscriber<>(subscriber, mapper)); + } + } + + /** + * Internal implementation of sync mapping publisher. + */ + private static class SyncMappingPublisher implements Flow.Publisher { + private final Flow.Publisher source; + private final Function mapper; + + public SyncMappingPublisher(Flow.Publisher source, Function mapper) { + this.source = source; + this.mapper = mapper; + } + + @Override + public void subscribe(Flow.Subscriber subscriber) { + source.subscribe(new SyncMappingSubscriber<>(subscriber, mapper)); + } + } + + /** + * Internal implementation of flattening publisher. + */ + private static class FlatteningPublisher implements Flow.Publisher { + private final Flow.Publisher source; + private final Function> flattener; + + public FlatteningPublisher(Flow.Publisher source, Function> flattener) { + this.source = source; + this.flattener = flattener; + } + + @Override + public void subscribe(Flow.Subscriber subscriber) { + source.subscribe(new FlatteningSubscriber<>(subscriber, flattener)); + } + } + + /** + * Internal implementation of concatenating publisher. + */ + private static final class ConcatPublisher implements Flow.Publisher { + private final List> pubs; + + ConcatPublisher(List> pubs) { + this.pubs = List.copyOf(pubs); + } + + @SuppressWarnings("unchecked") + @Override + public void subscribe(Flow.Subscriber downstream) { + downstream.onSubscribe(new ConcatSubscription<>((Flow.Subscriber) downstream, pubs.iterator())); + } + + } + + /** + * Subscriber that handles async mapping transformations. + */ + private static class AsyncMappingSubscriber implements Flow.Subscriber { + private final Flow.Subscriber downstream; + private final Function> mapper; + private final AtomicBoolean cancelled = new AtomicBoolean(false); + private final AtomicLong pendingDemand = new AtomicLong(0); + private final AtomicLong pendingCompletes = new AtomicLong(0); + private Flow.Subscription upstream; + private volatile boolean upstreamCompleted = false; + + public AsyncMappingSubscriber(Flow.Subscriber downstream, Function> mapper) { + this.downstream = downstream; + this.mapper = mapper; + } + + @Override + public void onSubscribe(Flow.Subscription subscription) { + this.upstream = subscription; + downstream.onSubscribe(new Flow.Subscription() { + @Override + public void request(long n) { + if (n <= 0) { + downstream.onError(new IllegalArgumentException("Request count must be positive")); + return; + } + + long currentDemand = pendingDemand.addAndGet(n); + if (currentDemand < 0) { + pendingDemand.set(Long.MAX_VALUE); + } + + upstream.request(n); + } + + @Override + public void cancel() { + cancelled.set(true); + upstream.cancel(); + } + }); + } + + @Override + public void onNext(T item) { + if (cancelled.get()) return; + + try { + pendingCompletes.incrementAndGet(); + CompletableFuture future = mapper.apply(item); + future.whenComplete((result, error) -> { + if (cancelled.get()) { + return; + } + + if (error != null) { + cancelled.set(true); + downstream.onError(error); + } else if (pendingDemand.get() > 0) { + pendingDemand.decrementAndGet(); + downstream.onNext(result); + } + + // Check if we should complete after this async operation + if (pendingCompletes.decrementAndGet() == 0 && upstreamCompleted) { + downstream.onComplete(); + } + }); + } catch (Exception e) { + if (!cancelled.get()) { + cancelled.set(true); + downstream.onError(e); + } + } + } + + @Override + public void onError(Throwable throwable) { + if (!cancelled.get()) { + downstream.onError(throwable); + } + } + + @Override + public void onComplete() { + upstreamCompleted = true; + if (!cancelled.get() && pendingCompletes.get() == 0) { + downstream.onComplete(); + } + } + } + + /** + * Subscriber that handles sync mapping transformations. + */ + private static class SyncMappingSubscriber implements Flow.Subscriber { + private final Flow.Subscriber downstream; + private final Function mapper; + private Flow.Subscription upstream; + private volatile boolean cancelled = false; + + public SyncMappingSubscriber(Flow.Subscriber downstream, Function mapper) { + this.downstream = downstream; + this.mapper = mapper; + } + + @Override + public void onSubscribe(Flow.Subscription subscription) { + this.upstream = subscription; + downstream.onSubscribe(new Flow.Subscription() { + @Override + public void request(long n) { + if (!cancelled) { + upstream.request(n); + } + } + + @Override + public void cancel() { + cancelled = true; + upstream.cancel(); + } + }); + } + + @Override + public void onNext(T item) { + if (cancelled) return; + + try { + R result = mapper.apply(item); + downstream.onNext(result); + } catch (Exception e) { + cancelled = true; + upstream.cancel(); + downstream.onError(e); + } + } + + @Override + public void onError(Throwable throwable) { + if (!cancelled) { + downstream.onError(throwable); + } + } + + @Override + public void onComplete() { + if (!cancelled) { + downstream.onComplete(); + } + } + } + + /** + * Subscriber that handles flattening transformations. + */ + private static class FlatteningSubscriber implements Flow.Subscriber { + private final Flow.Subscriber downstream; + private final Function> flattener; + private Flow.Subscription upstreamSubscription; + private volatile boolean cancelled = false; + + public FlatteningSubscriber(Flow.Subscriber downstream, Function> flattener) { + this.downstream = Objects.requireNonNull(downstream, "Downstream subscriber cannot be null"); + this.flattener = flattener; + } + + @Override + public void onSubscribe(Flow.Subscription subscription) { + this.upstreamSubscription = Objects.requireNonNull(subscription, "Upstream subscription cannot be null"); + downstream.onSubscribe(new Flow.Subscription() { + @Override + public void request(long n) { + if (n <= 0) { + downstream.onError(new IllegalArgumentException("Demand must be positive: " + n)); + return; + } + + if (!cancelled && upstreamSubscription != null) { + upstreamSubscription.request(n); + } + } + + @Override + public void cancel() { + cancelled = true; + if (upstreamSubscription != null) { + upstreamSubscription.cancel(); + } + } + }); + } + + @Override + public void onNext(T item) { + if (cancelled) { + return; + } + + try { + Iterable items = flattener.apply(item); + for (R flattenedItem : items) { + if (cancelled) { + break; + } + downstream.onNext(flattenedItem); + } + } catch (Exception e) { + if (!cancelled) { + cancelled = true; + upstreamSubscription.cancel(); + downstream.onError(e); + } + } + } + + @Override + public void onError(Throwable throwable) { + if (!cancelled) { + downstream.onError(throwable); + } + } + + @Override + public void onComplete() { + if (!cancelled) { + downstream.onComplete(); + } + } + } + + /** + * Subscriber that handles concatenating publishers. + */ + private static final class ConcatSubscription implements Flow.Subscription { + private final Flow.Subscriber downstream; + private final Iterator> it; + + private Flow.Subscription upstream; + private long demand = 0L; + private boolean cancelled = false; + private boolean completed = false; + + public ConcatSubscription(Flow.Subscriber downstream, + Iterator> it) { + this.downstream = downstream; + this.it = it; + } + + + @Override + public synchronized void request(long n) { + if (cancelled || completed || n <= 0) return; + demand = addCap(demand, n); + if (upstream == null) { + subscribeNext(); + } else { + upstream.request(n); + } + } + + @Override + public synchronized void cancel() { + cancelled = true; + if (upstream != null) upstream.cancel(); + } + + private void subscribeNext() { + if (cancelled) return; + if (!it.hasNext()) { + completed = true; + downstream.onComplete(); + return; + } + Flow.Publisher next = it.next(); + next.subscribe(new Upstream()); + } + + private final class Upstream implements Flow.Subscriber { + @Override + public void onSubscribe(Flow.Subscription s) { + synchronized (ConcatSubscription.this) { + upstream = s; + if (demand > 0) s.request(demand); + } + } + + @Override + public void onNext(T item) { + long afterDecrement; + synchronized (ConcatSubscription.this) { + if (demand == 0) return; // should not happen if upstream respects RS + demand--; + afterDecrement = demand; + } + downstream.onNext(item); + // no need to request here; downstream will call request() again if needed + } + + @Override + public void onError(Throwable t) { + downstream.onError(t); + } + + @Override + public void onComplete() { + synchronized (ConcatSubscription.this) { + upstream = null; + if (cancelled) return; + } + // carry over remaining demand to next publisher + subscribeNext(); + } + } + + private static long addCap(long a, long b) { + long r = a + b; + return (r < 0L) ? Long.MAX_VALUE : r; + } + } +} diff --git a/src/test/java/com/google/genai/HttpApiClientTest.java b/src/test/java/com/google/genai/HttpApiClientTest.java index a58520c9153..963655311b3 100644 --- a/src/test/java/com/google/genai/HttpApiClientTest.java +++ b/src/test/java/com/google/genai/HttpApiClientTest.java @@ -1758,6 +1758,7 @@ public void testCloseClient() { assertTrue(client.httpClient().dispatcher().executorService().isShutdown()); assertEquals(0, client.httpClient().connectionPool().connectionCount()); + } @Test