diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AgentEngines.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AgentEngines.java index dd81a7d..aec608f 100644 --- a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AgentEngines.java +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AgentEngines.java @@ -52,12 +52,14 @@ public final class AgentEngines { public final Sessions sessions; + public final Sandboxes sandboxes; final ApiClient apiClient; public AgentEngines(ApiClient apiClient) { this.apiClient = apiClient; this.sessions = new Sessions(apiClient); + this.sandboxes = new Sandboxes(apiClient); } @ExcludeFromGeneratedCoverageReport diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncAgentEngines.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncAgentEngines.java index 70c9450..f9a983a 100644 --- a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncAgentEngines.java +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncAgentEngines.java @@ -38,6 +38,7 @@ /** Async module of {@link AgentEngines} */ public final class AsyncAgentEngines { public final AsyncSessions sessions; + public final AsyncSandboxes sandboxes; AgentEngines agentEngines; ApiClient apiClient; @@ -47,6 +48,7 @@ public AsyncAgentEngines(ApiClient apiClient) { this.agentEngines = new AgentEngines(apiClient); this.sessions = new AsyncSessions(apiClient); + this.sandboxes = new AsyncSandboxes(apiClient); } CompletableFuture privateCreate(CreateAgentEngineConfig config) { diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncSandboxes.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncSandboxes.java new file mode 100644 index 0000000..5aa59ad --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncSandboxes.java @@ -0,0 +1,136 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai; + +import com.google.cloud.vertexai.genai.types.AgentEngineSandboxOperation; +import com.google.cloud.vertexai.genai.types.Chunk; +import com.google.cloud.vertexai.genai.types.CreateAgentEngineSandboxConfig; +import com.google.cloud.vertexai.genai.types.DeleteAgentEngineSandboxConfig; +import com.google.cloud.vertexai.genai.types.DeleteAgentEngineSandboxOperation; +import com.google.cloud.vertexai.genai.types.ExecuteCodeAgentEngineSandboxConfig; +import com.google.cloud.vertexai.genai.types.ExecuteSandboxEnvironmentResponse; +import com.google.cloud.vertexai.genai.types.GetAgentEngineOperationConfig; +import com.google.cloud.vertexai.genai.types.GetAgentEngineSandboxConfig; +import com.google.cloud.vertexai.genai.types.ListAgentEngineSandboxesConfig; +import com.google.cloud.vertexai.genai.types.ListAgentEngineSandboxesResponse; +import com.google.cloud.vertexai.genai.types.SandboxEnvironment; +import com.google.cloud.vertexai.genai.types.SandboxEnvironmentSpec; +import com.google.genai.ApiClient; +import com.google.genai.ApiResponse; +import com.google.genai.Common.BuiltRequest; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** Async module of {@link Sandboxes} */ +public final class AsyncSandboxes { + + Sandboxes sandboxes; + ApiClient apiClient; + + public AsyncSandboxes(ApiClient apiClient) { + this.apiClient = apiClient; + this.sandboxes = new Sandboxes(apiClient); + } + + CompletableFuture privateCreate( + String name, SandboxEnvironmentSpec spec, CreateAgentEngineSandboxConfig config) { + + BuiltRequest builtRequest = sandboxes.buildRequestForPrivateCreate(name, spec, config); + return this.apiClient + .asyncRequest("post", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions()) + .thenApplyAsync( + response -> { + try (ApiResponse res = response) { + return sandboxes.processResponseForPrivateCreate(res, config); + } + }); + } + + CompletableFuture privateDelete( + String name, DeleteAgentEngineSandboxConfig config) { + + BuiltRequest builtRequest = sandboxes.buildRequestForPrivateDelete(name, config); + return this.apiClient + .asyncRequest( + "delete", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions()) + .thenApplyAsync( + response -> { + try (ApiResponse res = response) { + return sandboxes.processResponseForPrivateDelete(res, config); + } + }); + } + + CompletableFuture privateExecuteCode( + String name, List inputs, ExecuteCodeAgentEngineSandboxConfig config) { + + BuiltRequest builtRequest = sandboxes.buildRequestForPrivateExecuteCode(name, inputs, config); + return this.apiClient + .asyncRequest("post", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions()) + .thenApplyAsync( + response -> { + try (ApiResponse res = response) { + return sandboxes.processResponseForPrivateExecuteCode(res, config); + } + }); + } + + CompletableFuture privateGet( + String name, GetAgentEngineSandboxConfig config) { + + BuiltRequest builtRequest = sandboxes.buildRequestForPrivateGet(name, config); + return this.apiClient + .asyncRequest("get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions()) + .thenApplyAsync( + response -> { + try (ApiResponse res = response) { + return sandboxes.processResponseForPrivateGet(res, config); + } + }); + } + + CompletableFuture privateList( + String name, ListAgentEngineSandboxesConfig config) { + + BuiltRequest builtRequest = sandboxes.buildRequestForPrivateList(name, config); + return this.apiClient + .asyncRequest("get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions()) + .thenApplyAsync( + response -> { + try (ApiResponse res = response) { + return sandboxes.processResponseForPrivateList(res, config); + } + }); + } + + CompletableFuture privateGetSandboxOperation( + String operationName, GetAgentEngineOperationConfig config) { + + BuiltRequest builtRequest = + sandboxes.buildRequestForPrivateGetSandboxOperation(operationName, config); + return this.apiClient + .asyncRequest("get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions()) + .thenApplyAsync( + response -> { + try (ApiResponse res = response) { + return sandboxes.processResponseForPrivateGetSandboxOperation(res, config); + } + }); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/Sandboxes.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/Sandboxes.java new file mode 100644 index 0000000..4f38ab6 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/Sandboxes.java @@ -0,0 +1,671 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.cloud.vertexai.genai.types.AgentEngineSandboxOperation; +import com.google.cloud.vertexai.genai.types.Chunk; +import com.google.cloud.vertexai.genai.types.CreateAgentEngineSandboxConfig; +import com.google.cloud.vertexai.genai.types.CreateAgentEngineSandboxRequestParameters; +import com.google.cloud.vertexai.genai.types.DeleteAgentEngineSandboxConfig; +import com.google.cloud.vertexai.genai.types.DeleteAgentEngineSandboxOperation; +import com.google.cloud.vertexai.genai.types.DeleteAgentEngineSandboxRequestParameters; +import com.google.cloud.vertexai.genai.types.ExecuteCodeAgentEngineSandboxConfig; +import com.google.cloud.vertexai.genai.types.ExecuteCodeAgentEngineSandboxRequestParameters; +import com.google.cloud.vertexai.genai.types.ExecuteSandboxEnvironmentResponse; +import com.google.cloud.vertexai.genai.types.GetAgentEngineOperationConfig; +import com.google.cloud.vertexai.genai.types.GetAgentEngineSandboxConfig; +import com.google.cloud.vertexai.genai.types.GetAgentEngineSandboxOperationParameters; +import com.google.cloud.vertexai.genai.types.GetAgentEngineSandboxRequestParameters; +import com.google.cloud.vertexai.genai.types.ListAgentEngineSandboxesConfig; +import com.google.cloud.vertexai.genai.types.ListAgentEngineSandboxesRequestParameters; +import com.google.cloud.vertexai.genai.types.ListAgentEngineSandboxesResponse; +import com.google.cloud.vertexai.genai.types.SandboxEnvironment; +import com.google.cloud.vertexai.genai.types.SandboxEnvironmentSpec; +import com.google.genai.ApiClient; +import com.google.genai.ApiResponse; +import com.google.genai.Common; +import com.google.genai.Common.BuiltRequest; +import com.google.genai.JsonSerializable; +import com.google.genai.errors.GenAiIOException; +import com.google.genai.types.HttpOptions; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import okhttp3.ResponseBody; + +public final class Sandboxes { + + final ApiClient apiClient; + + public Sandboxes(ApiClient apiClient) { + this.apiClient = apiClient; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode createAgentEngineSandboxConfigToVertex(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + + if (Common.getValueByPath(fromObject, new String[] {"displayName"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"displayName"}, + Common.getValueByPath(fromObject, new String[] {"displayName"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"description"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"description"}, + Common.getValueByPath(fromObject, new String[] {"description"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"ttl"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"ttl"}, + Common.getValueByPath(fromObject, new String[] {"ttl"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode createAgentEngineSandboxRequestParametersToVertex( + JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"_url", "name"}, + Common.getValueByPath(fromObject, new String[] {"name"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"spec"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"spec"}, + Common.getValueByPath(fromObject, new String[] {"spec"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) { + JsonNode unused = + createAgentEngineSandboxConfigToVertex( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"config"})), + toObject); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode deleteAgentEngineSandboxRequestParametersToVertex( + JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"_url", "name"}, + Common.getValueByPath(fromObject, new String[] {"name"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode executeCodeAgentEngineSandboxRequestParametersToVertex( + JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"_url", "name"}, + Common.getValueByPath(fromObject, new String[] {"name"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"inputs"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"inputs"}, + Common.getValueByPath(fromObject, new String[] {"inputs"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode getAgentEngineSandboxOperationParametersToVertex( + JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"operationName"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"_url", "operationName"}, + Common.getValueByPath(fromObject, new String[] {"operationName"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode getAgentEngineSandboxRequestParametersToVertex( + JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"_url", "name"}, + Common.getValueByPath(fromObject, new String[] {"name"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode listAgentEngineSandboxesConfigToVertex(JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + + if (Common.getValueByPath(fromObject, new String[] {"pageSize"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"_query", "pageSize"}, + Common.getValueByPath(fromObject, new String[] {"pageSize"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"pageToken"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"_query", "pageToken"}, + Common.getValueByPath(fromObject, new String[] {"pageToken"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"filter"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"_query", "filter"}, + Common.getValueByPath(fromObject, new String[] {"filter"})); + } + + return toObject; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode listAgentEngineSandboxesRequestParametersToVertex( + JsonNode fromObject, ObjectNode parentObject) { + ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"_url", "name"}, + Common.getValueByPath(fromObject, new String[] {"name"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) { + JsonNode unused = + listAgentEngineSandboxesConfigToVertex( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"config"})), + toObject); + } + + return toObject; + } + + /** A shared buildRequest method for both sync and async methods. */ + BuiltRequest buildRequestForPrivateCreate( + String name, SandboxEnvironmentSpec spec, CreateAgentEngineSandboxConfig config) { + + CreateAgentEngineSandboxRequestParameters.Builder parameterBuilder = + CreateAgentEngineSandboxRequestParameters.builder(); + + if (!Common.isZero(name)) { + parameterBuilder.name(name); + } + if (!Common.isZero(spec)) { + parameterBuilder.spec(spec); + } + if (!Common.isZero(config)) { + parameterBuilder.config(config); + } + JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build()); + + ObjectNode body; + String path; + if (this.apiClient.vertexAI()) { + body = createAgentEngineSandboxRequestParametersToVertex(parameterNode, null); + path = Common.formatMap("{name}/sandboxEnvironments", body.get("_url")); + } else { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + body.remove("_url"); + + JsonNode queryParams = body.get("_query"); + if (queryParams != null) { + body.remove("_query"); + path = String.format("%s?%s", path, Common.urlEncode((ObjectNode) queryParams)); + } + + // TODO: Remove the hack that removes config. + Optional requestHttpOptions = Optional.empty(); + if (config != null) { + requestHttpOptions = config.httpOptions(); + } + + return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions); + } + + /** A shared processResponse function for both sync and async methods. */ + AgentEngineSandboxOperation processResponseForPrivateCreate( + ApiResponse response, CreateAgentEngineSandboxConfig config) { + ResponseBody responseBody = response.getBody(); + String responseString; + try { + responseString = responseBody.string(); + } catch (IOException e) { + throw new GenAiIOException("Failed to read HTTP response.", e); + } + + JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString); + + if (!this.apiClient.vertexAI()) { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + + return JsonSerializable.fromJsonNode(responseNode, AgentEngineSandboxOperation.class); + } + + public AgentEngineSandboxOperation privateCreate( + String name, SandboxEnvironmentSpec spec, CreateAgentEngineSandboxConfig config) { + BuiltRequest builtRequest = buildRequestForPrivateCreate(name, spec, config); + + try (ApiResponse response = + this.apiClient.request( + "post", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions())) { + return processResponseForPrivateCreate(response, config); + } + } + + /** A shared buildRequest method for both sync and async methods. */ + BuiltRequest buildRequestForPrivateDelete(String name, DeleteAgentEngineSandboxConfig config) { + + DeleteAgentEngineSandboxRequestParameters.Builder parameterBuilder = + DeleteAgentEngineSandboxRequestParameters.builder(); + + if (!Common.isZero(name)) { + parameterBuilder.name(name); + } + if (!Common.isZero(config)) { + parameterBuilder.config(config); + } + JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build()); + + ObjectNode body; + String path; + if (this.apiClient.vertexAI()) { + body = deleteAgentEngineSandboxRequestParametersToVertex(parameterNode, null); + path = Common.formatMap("{name}", body.get("_url")); + } else { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + body.remove("_url"); + + JsonNode queryParams = body.get("_query"); + if (queryParams != null) { + body.remove("_query"); + path = String.format("%s?%s", path, Common.urlEncode((ObjectNode) queryParams)); + } + + // TODO: Remove the hack that removes config. + Optional requestHttpOptions = Optional.empty(); + if (config != null) { + requestHttpOptions = config.httpOptions(); + } + + return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions); + } + + /** A shared processResponse function for both sync and async methods. */ + DeleteAgentEngineSandboxOperation processResponseForPrivateDelete( + ApiResponse response, DeleteAgentEngineSandboxConfig config) { + ResponseBody responseBody = response.getBody(); + String responseString; + try { + responseString = responseBody.string(); + } catch (IOException e) { + throw new GenAiIOException("Failed to read HTTP response.", e); + } + + JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString); + + if (!this.apiClient.vertexAI()) { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + + return JsonSerializable.fromJsonNode(responseNode, DeleteAgentEngineSandboxOperation.class); + } + + public DeleteAgentEngineSandboxOperation privateDelete( + String name, DeleteAgentEngineSandboxConfig config) { + BuiltRequest builtRequest = buildRequestForPrivateDelete(name, config); + + try (ApiResponse response = + this.apiClient.request( + "delete", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions())) { + return processResponseForPrivateDelete(response, config); + } + } + + /** A shared buildRequest method for both sync and async methods. */ + BuiltRequest buildRequestForPrivateExecuteCode( + String name, List inputs, ExecuteCodeAgentEngineSandboxConfig config) { + + ExecuteCodeAgentEngineSandboxRequestParameters.Builder parameterBuilder = + ExecuteCodeAgentEngineSandboxRequestParameters.builder(); + + if (!Common.isZero(name)) { + parameterBuilder.name(name); + } + if (!Common.isZero(inputs)) { + parameterBuilder.inputs(inputs); + } + if (!Common.isZero(config)) { + parameterBuilder.config(config); + } + JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build()); + + ObjectNode body; + String path; + if (this.apiClient.vertexAI()) { + body = executeCodeAgentEngineSandboxRequestParametersToVertex(parameterNode, null); + path = Common.formatMap("{name}/:execute", body.get("_url")); + } else { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + body.remove("_url"); + + JsonNode queryParams = body.get("_query"); + if (queryParams != null) { + body.remove("_query"); + path = String.format("%s?%s", path, Common.urlEncode((ObjectNode) queryParams)); + } + + // TODO: Remove the hack that removes config. + Optional requestHttpOptions = Optional.empty(); + if (config != null) { + requestHttpOptions = config.httpOptions(); + } + + return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions); + } + + /** A shared processResponse function for both sync and async methods. */ + ExecuteSandboxEnvironmentResponse processResponseForPrivateExecuteCode( + ApiResponse response, ExecuteCodeAgentEngineSandboxConfig config) { + ResponseBody responseBody = response.getBody(); + String responseString; + try { + responseString = responseBody.string(); + } catch (IOException e) { + throw new GenAiIOException("Failed to read HTTP response.", e); + } + + JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString); + + if (!this.apiClient.vertexAI()) { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + + return JsonSerializable.fromJsonNode(responseNode, ExecuteSandboxEnvironmentResponse.class); + } + + public ExecuteSandboxEnvironmentResponse privateExecuteCode( + String name, List inputs, ExecuteCodeAgentEngineSandboxConfig config) { + BuiltRequest builtRequest = buildRequestForPrivateExecuteCode(name, inputs, config); + + try (ApiResponse response = + this.apiClient.request( + "post", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions())) { + return processResponseForPrivateExecuteCode(response, config); + } + } + + /** A shared buildRequest method for both sync and async methods. */ + BuiltRequest buildRequestForPrivateGet(String name, GetAgentEngineSandboxConfig config) { + + GetAgentEngineSandboxRequestParameters.Builder parameterBuilder = + GetAgentEngineSandboxRequestParameters.builder(); + + if (!Common.isZero(name)) { + parameterBuilder.name(name); + } + if (!Common.isZero(config)) { + parameterBuilder.config(config); + } + JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build()); + + ObjectNode body; + String path; + if (this.apiClient.vertexAI()) { + body = getAgentEngineSandboxRequestParametersToVertex(parameterNode, null); + path = Common.formatMap("{name}", body.get("_url")); + } else { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + body.remove("_url"); + + JsonNode queryParams = body.get("_query"); + if (queryParams != null) { + body.remove("_query"); + path = String.format("%s?%s", path, Common.urlEncode((ObjectNode) queryParams)); + } + + // TODO: Remove the hack that removes config. + Optional requestHttpOptions = Optional.empty(); + if (config != null) { + requestHttpOptions = config.httpOptions(); + } + + return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions); + } + + /** A shared processResponse function for both sync and async methods. */ + SandboxEnvironment processResponseForPrivateGet( + ApiResponse response, GetAgentEngineSandboxConfig config) { + ResponseBody responseBody = response.getBody(); + String responseString; + try { + responseString = responseBody.string(); + } catch (IOException e) { + throw new GenAiIOException("Failed to read HTTP response.", e); + } + + JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString); + + if (!this.apiClient.vertexAI()) { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + + return JsonSerializable.fromJsonNode(responseNode, SandboxEnvironment.class); + } + + public SandboxEnvironment privateGet(String name, GetAgentEngineSandboxConfig config) { + BuiltRequest builtRequest = buildRequestForPrivateGet(name, config); + + try (ApiResponse response = + this.apiClient.request( + "get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions())) { + return processResponseForPrivateGet(response, config); + } + } + + /** A shared buildRequest method for both sync and async methods. */ + BuiltRequest buildRequestForPrivateList(String name, ListAgentEngineSandboxesConfig config) { + + ListAgentEngineSandboxesRequestParameters.Builder parameterBuilder = + ListAgentEngineSandboxesRequestParameters.builder(); + + if (!Common.isZero(name)) { + parameterBuilder.name(name); + } + if (!Common.isZero(config)) { + parameterBuilder.config(config); + } + JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build()); + + ObjectNode body; + String path; + if (this.apiClient.vertexAI()) { + body = listAgentEngineSandboxesRequestParametersToVertex(parameterNode, null); + path = Common.formatMap("{name}/sandboxEnvironments", body.get("_url")); + } else { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + body.remove("_url"); + + JsonNode queryParams = body.get("_query"); + if (queryParams != null) { + body.remove("_query"); + path = String.format("%s?%s", path, Common.urlEncode((ObjectNode) queryParams)); + } + + // TODO: Remove the hack that removes config. + Optional requestHttpOptions = Optional.empty(); + if (config != null) { + requestHttpOptions = config.httpOptions(); + } + + return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions); + } + + /** A shared processResponse function for both sync and async methods. */ + ListAgentEngineSandboxesResponse processResponseForPrivateList( + ApiResponse response, ListAgentEngineSandboxesConfig config) { + ResponseBody responseBody = response.getBody(); + String responseString; + try { + responseString = responseBody.string(); + } catch (IOException e) { + throw new GenAiIOException("Failed to read HTTP response.", e); + } + + JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString); + + if (!this.apiClient.vertexAI()) { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + + return JsonSerializable.fromJsonNode(responseNode, ListAgentEngineSandboxesResponse.class); + } + + public ListAgentEngineSandboxesResponse privateList( + String name, ListAgentEngineSandboxesConfig config) { + BuiltRequest builtRequest = buildRequestForPrivateList(name, config); + + try (ApiResponse response = + this.apiClient.request( + "get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions())) { + return processResponseForPrivateList(response, config); + } + } + + /** A shared buildRequest method for both sync and async methods. */ + BuiltRequest buildRequestForPrivateGetSandboxOperation( + String operationName, GetAgentEngineOperationConfig config) { + + GetAgentEngineSandboxOperationParameters.Builder parameterBuilder = + GetAgentEngineSandboxOperationParameters.builder(); + + if (!Common.isZero(operationName)) { + parameterBuilder.operationName(operationName); + } + if (!Common.isZero(config)) { + parameterBuilder.config(config); + } + JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build()); + + ObjectNode body; + String path; + if (this.apiClient.vertexAI()) { + body = getAgentEngineSandboxOperationParametersToVertex(parameterNode, null); + path = Common.formatMap("{operationName}", body.get("_url")); + } else { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + body.remove("_url"); + + JsonNode queryParams = body.get("_query"); + if (queryParams != null) { + body.remove("_query"); + path = String.format("%s?%s", path, Common.urlEncode((ObjectNode) queryParams)); + } + + // TODO: Remove the hack that removes config. + Optional requestHttpOptions = Optional.empty(); + if (config != null) { + requestHttpOptions = config.httpOptions(); + } + + return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions); + } + + /** A shared processResponse function for both sync and async methods. */ + AgentEngineSandboxOperation processResponseForPrivateGetSandboxOperation( + ApiResponse response, GetAgentEngineOperationConfig config) { + ResponseBody responseBody = response.getBody(); + String responseString; + try { + responseString = responseBody.string(); + } catch (IOException e) { + throw new GenAiIOException("Failed to read HTTP response.", e); + } + + JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString); + + if (!this.apiClient.vertexAI()) { + throw new UnsupportedOperationException( + "This method is only supported in the Vertex AI client."); + } + + return JsonSerializable.fromJsonNode(responseNode, AgentEngineSandboxOperation.class); + } + + public AgentEngineSandboxOperation privateGetSandboxOperation( + String operationName, GetAgentEngineOperationConfig config) { + BuiltRequest builtRequest = buildRequestForPrivateGetSandboxOperation(operationName, config); + + try (ApiResponse response = + this.apiClient.request( + "get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions())) { + return processResponseForPrivateGetSandboxOperation(response, config); + } + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/AgentEngineSandboxOperation.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/AgentEngineSandboxOperation.java new file mode 100644 index 0000000..add419b --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/AgentEngineSandboxOperation.java @@ -0,0 +1,198 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Map; +import java.util.Optional; + +/** Operation that has an agent engine sandbox as a response. */ +@AutoValue +@JsonDeserialize(builder = AgentEngineSandboxOperation.Builder.class) +public abstract class AgentEngineSandboxOperation extends JsonSerializable { + /** + * The server-assigned name, which is only unique within the same service that originally returns + * it. If you use the default HTTP mapping, the `name` should be a resource name ending with + * `operations/{unique_id}`. + */ + @JsonProperty("name") + public abstract Optional name(); + + /** + * Service-specific metadata associated with the operation. It typically contains progress + * information and common metadata such as create time. Some services might not provide such + * metadata. Any method that returns a long-running operation should document the metadata type, + * if any. + */ + @JsonProperty("metadata") + public abstract Optional> metadata(); + + /** + * If the value is `false`, it means the operation is still in progress. If `true`, the operation + * is completed, and either `error` or `response` is available. + */ + @JsonProperty("done") + public abstract Optional done(); + + /** The error result of the operation in case of failure or cancellation. */ + @JsonProperty("error") + public abstract Optional> error(); + + /** The Agent Engine Sandbox. */ + @JsonProperty("response") + public abstract Optional response(); + + /** Instantiates a builder for AgentEngineSandboxOperation. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_AgentEngineSandboxOperation.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for AgentEngineSandboxOperation. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `AgentEngineSandboxOperation.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_AgentEngineSandboxOperation.Builder(); + } + + /** + * Setter for name. + * + *

name: The server-assigned name, which is only unique within the same service that + * originally returns it. If you use the default HTTP mapping, the `name` should be a resource + * name ending with `operations/{unique_id}`. + */ + @JsonProperty("name") + public abstract Builder name(String name); + + @ExcludeFromGeneratedCoverageReport + abstract Builder name(Optional name); + + /** Clears the value of name field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearName() { + return name(Optional.empty()); + } + + /** + * Setter for metadata. + * + *

metadata: Service-specific metadata associated with the operation. It typically contains + * progress information and common metadata such as create time. Some services might not provide + * such metadata. Any method that returns a long-running operation should document the metadata + * type, if any. + */ + @JsonProperty("metadata") + public abstract Builder metadata(Map metadata); + + @ExcludeFromGeneratedCoverageReport + abstract Builder metadata(Optional> metadata); + + /** Clears the value of metadata field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMetadata() { + return metadata(Optional.empty()); + } + + /** + * Setter for done. + * + *

done: If the value is `false`, it means the operation is still in progress. If `true`, the + * operation is completed, and either `error` or `response` is available. + */ + @JsonProperty("done") + public abstract Builder done(boolean done); + + @ExcludeFromGeneratedCoverageReport + abstract Builder done(Optional done); + + /** Clears the value of done field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDone() { + return done(Optional.empty()); + } + + /** + * Setter for error. + * + *

error: The error result of the operation in case of failure or cancellation. + */ + @JsonProperty("error") + public abstract Builder error(Map error); + + @ExcludeFromGeneratedCoverageReport + abstract Builder error(Optional> error); + + /** Clears the value of error field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearError() { + return error(Optional.empty()); + } + + /** + * Setter for response. + * + *

response: The Agent Engine Sandbox. + */ + @JsonProperty("response") + public abstract Builder response(SandboxEnvironment response); + + /** + * Setter for response builder. + * + *

response: The Agent Engine Sandbox. + */ + @CanIgnoreReturnValue + public Builder response(SandboxEnvironment.Builder responseBuilder) { + return response(responseBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder response(Optional response); + + /** Clears the value of response field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearResponse() { + return response(Optional.empty()); + } + + public abstract AgentEngineSandboxOperation build(); + } + + /** Deserializes a JSON string to a AgentEngineSandboxOperation object. */ + @ExcludeFromGeneratedCoverageReport + public static AgentEngineSandboxOperation fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, AgentEngineSandboxOperation.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Chunk.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Chunk.java new file mode 100644 index 0000000..2bd4d20 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Chunk.java @@ -0,0 +1,139 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** A chunk of data. */ +@AutoValue +@JsonDeserialize(builder = Chunk.Builder.class) +public abstract class Chunk extends JsonSerializable { + /** Required. The data in the chunk. */ + @JsonProperty("data") + public abstract Optional data(); + + /** Optional. Metadata that is associated with the data in the payload. */ + @JsonProperty("metadata") + public abstract Optional metadata(); + + /** + * Required. Mime type of the chunk data. See + * https://www.iana.org/assignments/media-types/media-types.xhtml for the full list. + */ + @JsonProperty("mimeType") + public abstract Optional mimeType(); + + /** Instantiates a builder for Chunk. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_Chunk.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for Chunk. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `Chunk.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_Chunk.Builder(); + } + + /** + * Setter for data. + * + *

data: Required. The data in the chunk. + */ + @JsonProperty("data") + public abstract Builder data(byte[] data); + + @ExcludeFromGeneratedCoverageReport + abstract Builder data(Optional data); + + /** Clears the value of data field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearData() { + return data(Optional.empty()); + } + + /** + * Setter for metadata. + * + *

metadata: Optional. Metadata that is associated with the data in the payload. + */ + @JsonProperty("metadata") + public abstract Builder metadata(Metadata metadata); + + /** + * Setter for metadata builder. + * + *

metadata: Optional. Metadata that is associated with the data in the payload. + */ + @CanIgnoreReturnValue + public Builder metadata(Metadata.Builder metadataBuilder) { + return metadata(metadataBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder metadata(Optional metadata); + + /** Clears the value of metadata field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMetadata() { + return metadata(Optional.empty()); + } + + /** + * Setter for mimeType. + * + *

mimeType: Required. Mime type of the chunk data. See + * https://www.iana.org/assignments/media-types/media-types.xhtml for the full list. + */ + @JsonProperty("mimeType") + public abstract Builder mimeType(String mimeType); + + @ExcludeFromGeneratedCoverageReport + abstract Builder mimeType(Optional mimeType); + + /** Clears the value of mimeType field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMimeType() { + return mimeType(Optional.empty()); + } + + public abstract Chunk build(); + } + + /** Deserializes a JSON string to a Chunk object. */ + @ExcludeFromGeneratedCoverageReport + public static Chunk fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, Chunk.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/CreateAgentEngineSandboxConfig.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/CreateAgentEngineSandboxConfig.java new file mode 100644 index 0000000..729657b --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/CreateAgentEngineSandboxConfig.java @@ -0,0 +1,173 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import com.google.genai.types.HttpOptions; +import java.time.Duration; +import java.util.Optional; + +/** Config for creating a Sandbox. */ +@AutoValue +@JsonDeserialize(builder = CreateAgentEngineSandboxConfig.Builder.class) +public abstract class CreateAgentEngineSandboxConfig extends JsonSerializable { + /** Used to override HTTP request options. */ + @JsonProperty("httpOptions") + public abstract Optional httpOptions(); + + /** The display name of the sandbox. */ + @JsonProperty("displayName") + public abstract Optional displayName(); + + /** The description of the sandbox. */ + @JsonProperty("description") + public abstract Optional description(); + + /** Waits for the operation to complete before returning. */ + @JsonProperty("waitForCompletion") + public abstract Optional waitForCompletion(); + + /** The TTL for this resource. The expiration time is computed: now + TTL. */ + @JsonProperty("ttl") + public abstract Optional ttl(); + + /** Instantiates a builder for CreateAgentEngineSandboxConfig. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_CreateAgentEngineSandboxConfig.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for CreateAgentEngineSandboxConfig. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `CreateAgentEngineSandboxConfig.builder()` for instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_CreateAgentEngineSandboxConfig.Builder(); + } + + /** + * Setter for httpOptions. + * + *

httpOptions: Used to override HTTP request options. + */ + @JsonProperty("httpOptions") + public abstract Builder httpOptions(HttpOptions httpOptions); + + @ExcludeFromGeneratedCoverageReport + abstract Builder httpOptions(Optional httpOptions); + + /** Clears the value of httpOptions field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearHttpOptions() { + return httpOptions(Optional.empty()); + } + + /** + * Setter for displayName. + * + *

displayName: The display name of the sandbox. + */ + @JsonProperty("displayName") + public abstract Builder displayName(String displayName); + + @ExcludeFromGeneratedCoverageReport + abstract Builder displayName(Optional displayName); + + /** Clears the value of displayName field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDisplayName() { + return displayName(Optional.empty()); + } + + /** + * Setter for description. + * + *

description: The description of the sandbox. + */ + @JsonProperty("description") + public abstract Builder description(String description); + + @ExcludeFromGeneratedCoverageReport + abstract Builder description(Optional description); + + /** Clears the value of description field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDescription() { + return description(Optional.empty()); + } + + /** + * Setter for waitForCompletion. + * + *

waitForCompletion: Waits for the operation to complete before returning. + */ + @JsonProperty("waitForCompletion") + public abstract Builder waitForCompletion(boolean waitForCompletion); + + @ExcludeFromGeneratedCoverageReport + abstract Builder waitForCompletion(Optional waitForCompletion); + + /** Clears the value of waitForCompletion field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearWaitForCompletion() { + return waitForCompletion(Optional.empty()); + } + + /** + * Setter for ttl. + * + *

ttl: The TTL for this resource. The expiration time is computed: now + TTL. + */ + @JsonProperty("ttl") + public abstract Builder ttl(Duration ttl); + + @ExcludeFromGeneratedCoverageReport + abstract Builder ttl(Optional ttl); + + /** Clears the value of ttl field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearTtl() { + return ttl(Optional.empty()); + } + + public abstract CreateAgentEngineSandboxConfig build(); + } + + /** Deserializes a JSON string to a CreateAgentEngineSandboxConfig object. */ + @ExcludeFromGeneratedCoverageReport + public static CreateAgentEngineSandboxConfig fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, CreateAgentEngineSandboxConfig.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/CreateAgentEngineSandboxRequestParameters.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/CreateAgentEngineSandboxRequestParameters.java new file mode 100644 index 0000000..86e3700 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/CreateAgentEngineSandboxRequestParameters.java @@ -0,0 +1,151 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.api.core.InternalApi; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Parameters for creating Agent Engine Sandboxes. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = CreateAgentEngineSandboxRequestParameters.Builder.class) +public abstract class CreateAgentEngineSandboxRequestParameters extends JsonSerializable { + /** Name of the agent engine to create the sandbox under. */ + @JsonProperty("name") + public abstract Optional name(); + + /** The specification of the sandbox. */ + @JsonProperty("spec") + public abstract Optional spec(); + + /** */ + @JsonProperty("config") + public abstract Optional config(); + + /** Instantiates a builder for CreateAgentEngineSandboxRequestParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_CreateAgentEngineSandboxRequestParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for CreateAgentEngineSandboxRequestParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `CreateAgentEngineSandboxRequestParameters.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_CreateAgentEngineSandboxRequestParameters.Builder(); + } + + /** + * Setter for name. + * + *

name: Name of the agent engine to create the sandbox under. + */ + @JsonProperty("name") + public abstract Builder name(String name); + + @ExcludeFromGeneratedCoverageReport + abstract Builder name(Optional name); + + /** Clears the value of name field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearName() { + return name(Optional.empty()); + } + + /** + * Setter for spec. + * + *

spec: The specification of the sandbox. + */ + @JsonProperty("spec") + public abstract Builder spec(SandboxEnvironmentSpec spec); + + /** + * Setter for spec builder. + * + *

spec: The specification of the sandbox. + */ + @CanIgnoreReturnValue + public Builder spec(SandboxEnvironmentSpec.Builder specBuilder) { + return spec(specBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder spec(Optional spec); + + /** Clears the value of spec field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSpec() { + return spec(Optional.empty()); + } + + /** + * Setter for config. + * + *

config: + */ + @JsonProperty("config") + public abstract Builder config(CreateAgentEngineSandboxConfig config); + + /** + * Setter for config builder. + * + *

config: + */ + @CanIgnoreReturnValue + public Builder config(CreateAgentEngineSandboxConfig.Builder configBuilder) { + return config(configBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder config(Optional config); + + /** Clears the value of config field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearConfig() { + return config(Optional.empty()); + } + + public abstract CreateAgentEngineSandboxRequestParameters build(); + } + + /** Deserializes a JSON string to a CreateAgentEngineSandboxRequestParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static CreateAgentEngineSandboxRequestParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, CreateAgentEngineSandboxRequestParameters.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxConfig.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxConfig.java new file mode 100644 index 0000000..b6b5884 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxConfig.java @@ -0,0 +1,84 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import com.google.genai.types.HttpOptions; +import java.util.Optional; + +/** Config for deleting an Agent Engine Sandbox. */ +@AutoValue +@JsonDeserialize(builder = DeleteAgentEngineSandboxConfig.Builder.class) +public abstract class DeleteAgentEngineSandboxConfig extends JsonSerializable { + /** Used to override HTTP request options. */ + @JsonProperty("httpOptions") + public abstract Optional httpOptions(); + + /** Instantiates a builder for DeleteAgentEngineSandboxConfig. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_DeleteAgentEngineSandboxConfig.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for DeleteAgentEngineSandboxConfig. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `DeleteAgentEngineSandboxConfig.builder()` for instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_DeleteAgentEngineSandboxConfig.Builder(); + } + + /** + * Setter for httpOptions. + * + *

httpOptions: Used to override HTTP request options. + */ + @JsonProperty("httpOptions") + public abstract Builder httpOptions(HttpOptions httpOptions); + + @ExcludeFromGeneratedCoverageReport + abstract Builder httpOptions(Optional httpOptions); + + /** Clears the value of httpOptions field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearHttpOptions() { + return httpOptions(Optional.empty()); + } + + public abstract DeleteAgentEngineSandboxConfig build(); + } + + /** Deserializes a JSON string to a DeleteAgentEngineSandboxConfig object. */ + @ExcludeFromGeneratedCoverageReport + public static DeleteAgentEngineSandboxConfig fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, DeleteAgentEngineSandboxConfig.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxOperation.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxOperation.java new file mode 100644 index 0000000..3fbe570 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxOperation.java @@ -0,0 +1,169 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Map; +import java.util.Optional; + +/** Operation for deleting agent engines. */ +@AutoValue +@JsonDeserialize(builder = DeleteAgentEngineSandboxOperation.Builder.class) +public abstract class DeleteAgentEngineSandboxOperation extends JsonSerializable { + /** + * The server-assigned name, which is only unique within the same service that originally returns + * it. If you use the default HTTP mapping, the `name` should be a resource name ending with + * `operations/{unique_id}`. + */ + @JsonProperty("name") + public abstract Optional name(); + + /** + * Service-specific metadata associated with the operation. It typically contains progress + * information and common metadata such as create time. Some services might not provide such + * metadata. Any method that returns a long-running operation should document the metadata type, + * if any. + */ + @JsonProperty("metadata") + public abstract Optional> metadata(); + + /** + * If the value is `false`, it means the operation is still in progress. If `true`, the operation + * is completed, and either `error` or `response` is available. + */ + @JsonProperty("done") + public abstract Optional done(); + + /** The error result of the operation in case of failure or cancellation. */ + @JsonProperty("error") + public abstract Optional> error(); + + /** Instantiates a builder for DeleteAgentEngineSandboxOperation. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_DeleteAgentEngineSandboxOperation.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for DeleteAgentEngineSandboxOperation. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `DeleteAgentEngineSandboxOperation.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_DeleteAgentEngineSandboxOperation.Builder(); + } + + /** + * Setter for name. + * + *

name: The server-assigned name, which is only unique within the same service that + * originally returns it. If you use the default HTTP mapping, the `name` should be a resource + * name ending with `operations/{unique_id}`. + */ + @JsonProperty("name") + public abstract Builder name(String name); + + @ExcludeFromGeneratedCoverageReport + abstract Builder name(Optional name); + + /** Clears the value of name field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearName() { + return name(Optional.empty()); + } + + /** + * Setter for metadata. + * + *

metadata: Service-specific metadata associated with the operation. It typically contains + * progress information and common metadata such as create time. Some services might not provide + * such metadata. Any method that returns a long-running operation should document the metadata + * type, if any. + */ + @JsonProperty("metadata") + public abstract Builder metadata(Map metadata); + + @ExcludeFromGeneratedCoverageReport + abstract Builder metadata(Optional> metadata); + + /** Clears the value of metadata field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMetadata() { + return metadata(Optional.empty()); + } + + /** + * Setter for done. + * + *

done: If the value is `false`, it means the operation is still in progress. If `true`, the + * operation is completed, and either `error` or `response` is available. + */ + @JsonProperty("done") + public abstract Builder done(boolean done); + + @ExcludeFromGeneratedCoverageReport + abstract Builder done(Optional done); + + /** Clears the value of done field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDone() { + return done(Optional.empty()); + } + + /** + * Setter for error. + * + *

error: The error result of the operation in case of failure or cancellation. + */ + @JsonProperty("error") + public abstract Builder error(Map error); + + @ExcludeFromGeneratedCoverageReport + abstract Builder error(Optional> error); + + /** Clears the value of error field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearError() { + return error(Optional.empty()); + } + + public abstract DeleteAgentEngineSandboxOperation build(); + } + + /** Deserializes a JSON string to a DeleteAgentEngineSandboxOperation object. */ + @ExcludeFromGeneratedCoverageReport + public static DeleteAgentEngineSandboxOperation fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, DeleteAgentEngineSandboxOperation.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxRequestParameters.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxRequestParameters.java new file mode 100644 index 0000000..8b26476 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/DeleteAgentEngineSandboxRequestParameters.java @@ -0,0 +1,119 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.api.core.InternalApi; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Parameters for deleting agent engines. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = DeleteAgentEngineSandboxRequestParameters.Builder.class) +public abstract class DeleteAgentEngineSandboxRequestParameters extends JsonSerializable { + /** Name of the agent engine sandbox to delete. */ + @JsonProperty("name") + public abstract Optional name(); + + /** */ + @JsonProperty("config") + public abstract Optional config(); + + /** Instantiates a builder for DeleteAgentEngineSandboxRequestParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_DeleteAgentEngineSandboxRequestParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for DeleteAgentEngineSandboxRequestParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `DeleteAgentEngineSandboxRequestParameters.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_DeleteAgentEngineSandboxRequestParameters.Builder(); + } + + /** + * Setter for name. + * + *

name: Name of the agent engine sandbox to delete. + */ + @JsonProperty("name") + public abstract Builder name(String name); + + @ExcludeFromGeneratedCoverageReport + abstract Builder name(Optional name); + + /** Clears the value of name field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearName() { + return name(Optional.empty()); + } + + /** + * Setter for config. + * + *

config: + */ + @JsonProperty("config") + public abstract Builder config(DeleteAgentEngineSandboxConfig config); + + /** + * Setter for config builder. + * + *

config: + */ + @CanIgnoreReturnValue + public Builder config(DeleteAgentEngineSandboxConfig.Builder configBuilder) { + return config(configBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder config(Optional config); + + /** Clears the value of config field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearConfig() { + return config(Optional.empty()); + } + + public abstract DeleteAgentEngineSandboxRequestParameters build(); + } + + /** Deserializes a JSON string to a DeleteAgentEngineSandboxRequestParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static DeleteAgentEngineSandboxRequestParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, DeleteAgentEngineSandboxRequestParameters.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteCodeAgentEngineSandboxConfig.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteCodeAgentEngineSandboxConfig.java new file mode 100644 index 0000000..93fbf16 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteCodeAgentEngineSandboxConfig.java @@ -0,0 +1,85 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import com.google.genai.types.HttpOptions; +import java.util.Optional; + +/** Config for executing code in an Agent Engine sandbox. */ +@AutoValue +@JsonDeserialize(builder = ExecuteCodeAgentEngineSandboxConfig.Builder.class) +public abstract class ExecuteCodeAgentEngineSandboxConfig extends JsonSerializable { + /** Used to override HTTP request options. */ + @JsonProperty("httpOptions") + public abstract Optional httpOptions(); + + /** Instantiates a builder for ExecuteCodeAgentEngineSandboxConfig. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ExecuteCodeAgentEngineSandboxConfig.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ExecuteCodeAgentEngineSandboxConfig. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ExecuteCodeAgentEngineSandboxConfig.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ExecuteCodeAgentEngineSandboxConfig.Builder(); + } + + /** + * Setter for httpOptions. + * + *

httpOptions: Used to override HTTP request options. + */ + @JsonProperty("httpOptions") + public abstract Builder httpOptions(HttpOptions httpOptions); + + @ExcludeFromGeneratedCoverageReport + abstract Builder httpOptions(Optional httpOptions); + + /** Clears the value of httpOptions field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearHttpOptions() { + return httpOptions(Optional.empty()); + } + + public abstract ExecuteCodeAgentEngineSandboxConfig build(); + } + + /** Deserializes a JSON string to a ExecuteCodeAgentEngineSandboxConfig object. */ + @ExcludeFromGeneratedCoverageReport + public static ExecuteCodeAgentEngineSandboxConfig fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ExecuteCodeAgentEngineSandboxConfig.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteCodeAgentEngineSandboxRequestParameters.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteCodeAgentEngineSandboxRequestParameters.java new file mode 100644 index 0000000..10faf25 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteCodeAgentEngineSandboxRequestParameters.java @@ -0,0 +1,168 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import static com.google.common.collect.ImmutableList.toImmutableList; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.api.core.InternalApi; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +/** Parameters for executing code in an agent engine sandbox. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = ExecuteCodeAgentEngineSandboxRequestParameters.Builder.class) +public abstract class ExecuteCodeAgentEngineSandboxRequestParameters extends JsonSerializable { + /** Name of the agent engine sandbox to execute code in. */ + @JsonProperty("name") + public abstract Optional name(); + + /** Inputs to the code execution. */ + @JsonProperty("inputs") + public abstract Optional> inputs(); + + /** */ + @JsonProperty("config") + public abstract Optional config(); + + /** Instantiates a builder for ExecuteCodeAgentEngineSandboxRequestParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ExecuteCodeAgentEngineSandboxRequestParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ExecuteCodeAgentEngineSandboxRequestParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ExecuteCodeAgentEngineSandboxRequestParameters.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ExecuteCodeAgentEngineSandboxRequestParameters.Builder(); + } + + /** + * Setter for name. + * + *

name: Name of the agent engine sandbox to execute code in. + */ + @JsonProperty("name") + public abstract Builder name(String name); + + @ExcludeFromGeneratedCoverageReport + abstract Builder name(Optional name); + + /** Clears the value of name field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearName() { + return name(Optional.empty()); + } + + /** + * Setter for inputs. + * + *

inputs: Inputs to the code execution. + */ + @JsonProperty("inputs") + public abstract Builder inputs(List inputs); + + /** + * Setter for inputs. + * + *

inputs: Inputs to the code execution. + */ + @CanIgnoreReturnValue + public Builder inputs(Chunk... inputs) { + return inputs(Arrays.asList(inputs)); + } + + /** + * Setter for inputs builder. + * + *

inputs: Inputs to the code execution. + */ + @CanIgnoreReturnValue + public Builder inputs(Chunk.Builder... inputsBuilders) { + return inputs( + Arrays.asList(inputsBuilders).stream() + .map(Chunk.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder inputs(Optional> inputs); + + /** Clears the value of inputs field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearInputs() { + return inputs(Optional.empty()); + } + + /** + * Setter for config. + * + *

config: + */ + @JsonProperty("config") + public abstract Builder config(ExecuteCodeAgentEngineSandboxConfig config); + + /** + * Setter for config builder. + * + *

config: + */ + @CanIgnoreReturnValue + public Builder config(ExecuteCodeAgentEngineSandboxConfig.Builder configBuilder) { + return config(configBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder config(Optional config); + + /** Clears the value of config field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearConfig() { + return config(Optional.empty()); + } + + public abstract ExecuteCodeAgentEngineSandboxRequestParameters build(); + } + + /** Deserializes a JSON string to a ExecuteCodeAgentEngineSandboxRequestParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static ExecuteCodeAgentEngineSandboxRequestParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ExecuteCodeAgentEngineSandboxRequestParameters.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteSandboxEnvironmentResponse.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteSandboxEnvironmentResponse.java new file mode 100644 index 0000000..5908af1 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ExecuteSandboxEnvironmentResponse.java @@ -0,0 +1,111 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import static com.google.common.collect.ImmutableList.toImmutableList; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +/** The response for executing a sandbox environment. */ +@AutoValue +@JsonDeserialize(builder = ExecuteSandboxEnvironmentResponse.Builder.class) +public abstract class ExecuteSandboxEnvironmentResponse extends JsonSerializable { + /** The outputs from the sandbox environment. */ + @JsonProperty("outputs") + public abstract Optional> outputs(); + + /** Instantiates a builder for ExecuteSandboxEnvironmentResponse. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ExecuteSandboxEnvironmentResponse.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ExecuteSandboxEnvironmentResponse. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ExecuteSandboxEnvironmentResponse.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ExecuteSandboxEnvironmentResponse.Builder(); + } + + /** + * Setter for outputs. + * + *

outputs: The outputs from the sandbox environment. + */ + @JsonProperty("outputs") + public abstract Builder outputs(List outputs); + + /** + * Setter for outputs. + * + *

outputs: The outputs from the sandbox environment. + */ + @CanIgnoreReturnValue + public Builder outputs(Chunk... outputs) { + return outputs(Arrays.asList(outputs)); + } + + /** + * Setter for outputs builder. + * + *

outputs: The outputs from the sandbox environment. + */ + @CanIgnoreReturnValue + public Builder outputs(Chunk.Builder... outputsBuilders) { + return outputs( + Arrays.asList(outputsBuilders).stream() + .map(Chunk.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder outputs(Optional> outputs); + + /** Clears the value of outputs field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearOutputs() { + return outputs(Optional.empty()); + } + + public abstract ExecuteSandboxEnvironmentResponse build(); + } + + /** Deserializes a JSON string to a ExecuteSandboxEnvironmentResponse object. */ + @ExcludeFromGeneratedCoverageReport + public static ExecuteSandboxEnvironmentResponse fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ExecuteSandboxEnvironmentResponse.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxConfig.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxConfig.java new file mode 100644 index 0000000..4165bff --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxConfig.java @@ -0,0 +1,82 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import com.google.genai.types.HttpOptions; +import java.util.Optional; + +/** Config for getting an Agent Engine Memory. */ +@AutoValue +@JsonDeserialize(builder = GetAgentEngineSandboxConfig.Builder.class) +public abstract class GetAgentEngineSandboxConfig extends JsonSerializable { + /** Used to override HTTP request options. */ + @JsonProperty("httpOptions") + public abstract Optional httpOptions(); + + /** Instantiates a builder for GetAgentEngineSandboxConfig. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_GetAgentEngineSandboxConfig.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for GetAgentEngineSandboxConfig. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `GetAgentEngineSandboxConfig.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_GetAgentEngineSandboxConfig.Builder(); + } + + /** + * Setter for httpOptions. + * + *

httpOptions: Used to override HTTP request options. + */ + @JsonProperty("httpOptions") + public abstract Builder httpOptions(HttpOptions httpOptions); + + @ExcludeFromGeneratedCoverageReport + abstract Builder httpOptions(Optional httpOptions); + + /** Clears the value of httpOptions field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearHttpOptions() { + return httpOptions(Optional.empty()); + } + + public abstract GetAgentEngineSandboxConfig build(); + } + + /** Deserializes a JSON string to a GetAgentEngineSandboxConfig object. */ + @ExcludeFromGeneratedCoverageReport + public static GetAgentEngineSandboxConfig fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, GetAgentEngineSandboxConfig.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxOperationParameters.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxOperationParameters.java new file mode 100644 index 0000000..dbde41b --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxOperationParameters.java @@ -0,0 +1,119 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.api.core.InternalApi; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Parameters for getting an operation with a sandbox as a response. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = GetAgentEngineSandboxOperationParameters.Builder.class) +public abstract class GetAgentEngineSandboxOperationParameters extends JsonSerializable { + /** The server-assigned name for the operation. */ + @JsonProperty("operationName") + public abstract Optional operationName(); + + /** Used to override the default configuration. */ + @JsonProperty("config") + public abstract Optional config(); + + /** Instantiates a builder for GetAgentEngineSandboxOperationParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_GetAgentEngineSandboxOperationParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for GetAgentEngineSandboxOperationParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `GetAgentEngineSandboxOperationParameters.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_GetAgentEngineSandboxOperationParameters.Builder(); + } + + /** + * Setter for operationName. + * + *

operationName: The server-assigned name for the operation. + */ + @JsonProperty("operationName") + public abstract Builder operationName(String operationName); + + @ExcludeFromGeneratedCoverageReport + abstract Builder operationName(Optional operationName); + + /** Clears the value of operationName field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearOperationName() { + return operationName(Optional.empty()); + } + + /** + * Setter for config. + * + *

config: Used to override the default configuration. + */ + @JsonProperty("config") + public abstract Builder config(GetAgentEngineOperationConfig config); + + /** + * Setter for config builder. + * + *

config: Used to override the default configuration. + */ + @CanIgnoreReturnValue + public Builder config(GetAgentEngineOperationConfig.Builder configBuilder) { + return config(configBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder config(Optional config); + + /** Clears the value of config field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearConfig() { + return config(Optional.empty()); + } + + public abstract GetAgentEngineSandboxOperationParameters build(); + } + + /** Deserializes a JSON string to a GetAgentEngineSandboxOperationParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static GetAgentEngineSandboxOperationParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, GetAgentEngineSandboxOperationParameters.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxRequestParameters.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxRequestParameters.java new file mode 100644 index 0000000..f96bf83 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineSandboxRequestParameters.java @@ -0,0 +1,119 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.api.core.InternalApi; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Parameters for getting an agent engine sandbox. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = GetAgentEngineSandboxRequestParameters.Builder.class) +public abstract class GetAgentEngineSandboxRequestParameters extends JsonSerializable { + /** Name of the agent engine sandbox. */ + @JsonProperty("name") + public abstract Optional name(); + + /** */ + @JsonProperty("config") + public abstract Optional config(); + + /** Instantiates a builder for GetAgentEngineSandboxRequestParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_GetAgentEngineSandboxRequestParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for GetAgentEngineSandboxRequestParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `GetAgentEngineSandboxRequestParameters.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_GetAgentEngineSandboxRequestParameters.Builder(); + } + + /** + * Setter for name. + * + *

name: Name of the agent engine sandbox. + */ + @JsonProperty("name") + public abstract Builder name(String name); + + @ExcludeFromGeneratedCoverageReport + abstract Builder name(Optional name); + + /** Clears the value of name field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearName() { + return name(Optional.empty()); + } + + /** + * Setter for config. + * + *

config: + */ + @JsonProperty("config") + public abstract Builder config(GetAgentEngineSandboxConfig config); + + /** + * Setter for config builder. + * + *

config: + */ + @CanIgnoreReturnValue + public Builder config(GetAgentEngineSandboxConfig.Builder configBuilder) { + return config(configBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder config(Optional config); + + /** Clears the value of config field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearConfig() { + return config(Optional.empty()); + } + + public abstract GetAgentEngineSandboxRequestParameters build(); + } + + /** Deserializes a JSON string to a GetAgentEngineSandboxRequestParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static GetAgentEngineSandboxRequestParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, GetAgentEngineSandboxRequestParameters.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Language.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Language.java new file mode 100644 index 0000000..a81c588 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Language.java @@ -0,0 +1,111 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.base.Ascii; +import java.util.Objects; + +/** The coding language supported in this environment. */ +public class Language { + + /** Enum representing the known values for Language. */ + public enum Known { + /** The default value. This value is unused. */ + LANGUAGE_UNSPECIFIED, + + /** The coding language is Python. */ + LANGUAGE_PYTHON, + + /** The coding language is JavaScript. */ + LANGUAGE_JAVASCRIPT + } + + private Known languageEnum; + private final String value; + + @JsonCreator + public Language(String value) { + this.value = value; + for (Known languageEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(languageEnum.toString(), value)) { + this.languageEnum = languageEnum; + break; + } + } + if (this.languageEnum == null) { + this.languageEnum = Known.LANGUAGE_UNSPECIFIED; + } + } + + public Language(Known knownValue) { + this.languageEnum = knownValue; + this.value = knownValue.toString(); + } + + @ExcludeFromGeneratedCoverageReport + @Override + @JsonValue + public String toString() { + return this.value; + } + + @ExcludeFromGeneratedCoverageReport + @SuppressWarnings("PatternMatchingInstanceof") + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null) { + return false; + } + + if (!(o instanceof Language)) { + return false; + } + + Language other = (Language) o; + + if (this.languageEnum != Known.LANGUAGE_UNSPECIFIED + && other.languageEnum != Known.LANGUAGE_UNSPECIFIED) { + return this.languageEnum == other.languageEnum; + } else if (this.languageEnum == Known.LANGUAGE_UNSPECIFIED + && other.languageEnum == Known.LANGUAGE_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.languageEnum != Known.LANGUAGE_UNSPECIFIED) { + return this.languageEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.languageEnum; + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesConfig.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesConfig.java new file mode 100644 index 0000000..f3685ea --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesConfig.java @@ -0,0 +1,154 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import com.google.genai.types.HttpOptions; +import java.util.Optional; + +/** Config for listing agent engine sandboxes. */ +@AutoValue +@JsonDeserialize(builder = ListAgentEngineSandboxesConfig.Builder.class) +public abstract class ListAgentEngineSandboxesConfig extends JsonSerializable { + /** Used to override HTTP request options. */ + @JsonProperty("httpOptions") + public abstract Optional httpOptions(); + + /** */ + @JsonProperty("pageSize") + public abstract Optional pageSize(); + + /** */ + @JsonProperty("pageToken") + public abstract Optional pageToken(); + + /** + * An expression for filtering the results of the request. For field names both snake_case and + * camelCase are supported. + */ + @JsonProperty("filter") + public abstract Optional filter(); + + /** Instantiates a builder for ListAgentEngineSandboxesConfig. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ListAgentEngineSandboxesConfig.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ListAgentEngineSandboxesConfig. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ListAgentEngineSandboxesConfig.builder()` for instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ListAgentEngineSandboxesConfig.Builder(); + } + + /** + * Setter for httpOptions. + * + *

httpOptions: Used to override HTTP request options. + */ + @JsonProperty("httpOptions") + public abstract Builder httpOptions(HttpOptions httpOptions); + + @ExcludeFromGeneratedCoverageReport + abstract Builder httpOptions(Optional httpOptions); + + /** Clears the value of httpOptions field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearHttpOptions() { + return httpOptions(Optional.empty()); + } + + /** + * Setter for pageSize. + * + *

pageSize: + */ + @JsonProperty("pageSize") + public abstract Builder pageSize(Integer pageSize); + + @ExcludeFromGeneratedCoverageReport + abstract Builder pageSize(Optional pageSize); + + /** Clears the value of pageSize field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearPageSize() { + return pageSize(Optional.empty()); + } + + /** + * Setter for pageToken. + * + *

pageToken: + */ + @JsonProperty("pageToken") + public abstract Builder pageToken(String pageToken); + + @ExcludeFromGeneratedCoverageReport + abstract Builder pageToken(Optional pageToken); + + /** Clears the value of pageToken field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearPageToken() { + return pageToken(Optional.empty()); + } + + /** + * Setter for filter. + * + *

filter: An expression for filtering the results of the request. For field names both + * snake_case and camelCase are supported. + */ + @JsonProperty("filter") + public abstract Builder filter(String filter); + + @ExcludeFromGeneratedCoverageReport + abstract Builder filter(Optional filter); + + /** Clears the value of filter field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearFilter() { + return filter(Optional.empty()); + } + + public abstract ListAgentEngineSandboxesConfig build(); + } + + /** Deserializes a JSON string to a ListAgentEngineSandboxesConfig object. */ + @ExcludeFromGeneratedCoverageReport + public static ListAgentEngineSandboxesConfig fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ListAgentEngineSandboxesConfig.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesRequestParameters.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesRequestParameters.java new file mode 100644 index 0000000..5359497 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesRequestParameters.java @@ -0,0 +1,119 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.api.core.InternalApi; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Parameters for listing agent engine sandboxes. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = ListAgentEngineSandboxesRequestParameters.Builder.class) +public abstract class ListAgentEngineSandboxesRequestParameters extends JsonSerializable { + /** Name of the agent engine. */ + @JsonProperty("name") + public abstract Optional name(); + + /** */ + @JsonProperty("config") + public abstract Optional config(); + + /** Instantiates a builder for ListAgentEngineSandboxesRequestParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ListAgentEngineSandboxesRequestParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ListAgentEngineSandboxesRequestParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ListAgentEngineSandboxesRequestParameters.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ListAgentEngineSandboxesRequestParameters.Builder(); + } + + /** + * Setter for name. + * + *

name: Name of the agent engine. + */ + @JsonProperty("name") + public abstract Builder name(String name); + + @ExcludeFromGeneratedCoverageReport + abstract Builder name(Optional name); + + /** Clears the value of name field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearName() { + return name(Optional.empty()); + } + + /** + * Setter for config. + * + *

config: + */ + @JsonProperty("config") + public abstract Builder config(ListAgentEngineSandboxesConfig config); + + /** + * Setter for config builder. + * + *

config: + */ + @CanIgnoreReturnValue + public Builder config(ListAgentEngineSandboxesConfig.Builder configBuilder) { + return config(configBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder config(Optional config); + + /** Clears the value of config field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearConfig() { + return config(Optional.empty()); + } + + public abstract ListAgentEngineSandboxesRequestParameters build(); + } + + /** Deserializes a JSON string to a ListAgentEngineSandboxesRequestParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static ListAgentEngineSandboxesRequestParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ListAgentEngineSandboxesRequestParameters.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesResponse.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesResponse.java new file mode 100644 index 0000000..ec0a2d2 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineSandboxesResponse.java @@ -0,0 +1,156 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import static com.google.common.collect.ImmutableList.toImmutableList; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import com.google.genai.types.HttpResponse; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +/** Response for listing agent engine sandboxes. */ +@AutoValue +@JsonDeserialize(builder = ListAgentEngineSandboxesResponse.Builder.class) +public abstract class ListAgentEngineSandboxesResponse extends JsonSerializable { + /** Used to retain the full HTTP response. */ + @JsonProperty("sdkHttpResponse") + public abstract Optional sdkHttpResponse(); + + /** */ + @JsonProperty("nextPageToken") + public abstract Optional nextPageToken(); + + /** List of agent engine sandboxes. */ + @JsonProperty("sandboxEnvironments") + public abstract Optional> sandboxEnvironments(); + + /** Instantiates a builder for ListAgentEngineSandboxesResponse. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ListAgentEngineSandboxesResponse.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ListAgentEngineSandboxesResponse. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ListAgentEngineSandboxesResponse.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ListAgentEngineSandboxesResponse.Builder(); + } + + /** + * Setter for sdkHttpResponse. + * + *

sdkHttpResponse: Used to retain the full HTTP response. + */ + @JsonProperty("sdkHttpResponse") + public abstract Builder sdkHttpResponse(HttpResponse sdkHttpResponse); + + @ExcludeFromGeneratedCoverageReport + abstract Builder sdkHttpResponse(Optional sdkHttpResponse); + + /** Clears the value of sdkHttpResponse field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSdkHttpResponse() { + return sdkHttpResponse(Optional.empty()); + } + + /** + * Setter for nextPageToken. + * + *

nextPageToken: + */ + @JsonProperty("nextPageToken") + public abstract Builder nextPageToken(String nextPageToken); + + @ExcludeFromGeneratedCoverageReport + abstract Builder nextPageToken(Optional nextPageToken); + + /** Clears the value of nextPageToken field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearNextPageToken() { + return nextPageToken(Optional.empty()); + } + + /** + * Setter for sandboxEnvironments. + * + *

sandboxEnvironments: List of agent engine sandboxes. + */ + @JsonProperty("sandboxEnvironments") + public abstract Builder sandboxEnvironments(List sandboxEnvironments); + + /** + * Setter for sandboxEnvironments. + * + *

sandboxEnvironments: List of agent engine sandboxes. + */ + @CanIgnoreReturnValue + public Builder sandboxEnvironments(SandboxEnvironment... sandboxEnvironments) { + return sandboxEnvironments(Arrays.asList(sandboxEnvironments)); + } + + /** + * Setter for sandboxEnvironments builder. + * + *

sandboxEnvironments: List of agent engine sandboxes. + */ + @CanIgnoreReturnValue + public Builder sandboxEnvironments(SandboxEnvironment.Builder... sandboxEnvironmentsBuilders) { + return sandboxEnvironments( + Arrays.asList(sandboxEnvironmentsBuilders).stream() + .map(SandboxEnvironment.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder sandboxEnvironments(Optional> sandboxEnvironments); + + /** Clears the value of sandboxEnvironments field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSandboxEnvironments() { + return sandboxEnvironments(Optional.empty()); + } + + public abstract ListAgentEngineSandboxesResponse build(); + } + + /** Deserializes a JSON string to a ListAgentEngineSandboxesResponse object. */ + @ExcludeFromGeneratedCoverageReport + public static ListAgentEngineSandboxesResponse fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ListAgentEngineSandboxesResponse.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/MachineConfig.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/MachineConfig.java new file mode 100644 index 0000000..21593ea --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/MachineConfig.java @@ -0,0 +1,108 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.base.Ascii; +import java.util.Objects; + +/** The machine config of the code execution environment. */ +public class MachineConfig { + + /** Enum representing the known values for MachineConfig. */ + public enum Known { + /** The default value: milligcu 2000, memory 1.5Gib */ + MACHINE_CONFIG_UNSPECIFIED, + + /** The default value: milligcu 4000, memory 4 Gib */ + MACHINE_CONFIG_VCPU4_RAM4GIB + } + + private Known machineConfigEnum; + private final String value; + + @JsonCreator + public MachineConfig(String value) { + this.value = value; + for (Known machineConfigEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(machineConfigEnum.toString(), value)) { + this.machineConfigEnum = machineConfigEnum; + break; + } + } + if (this.machineConfigEnum == null) { + this.machineConfigEnum = Known.MACHINE_CONFIG_UNSPECIFIED; + } + } + + public MachineConfig(Known knownValue) { + this.machineConfigEnum = knownValue; + this.value = knownValue.toString(); + } + + @ExcludeFromGeneratedCoverageReport + @Override + @JsonValue + public String toString() { + return this.value; + } + + @ExcludeFromGeneratedCoverageReport + @SuppressWarnings("PatternMatchingInstanceof") + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null) { + return false; + } + + if (!(o instanceof MachineConfig)) { + return false; + } + + MachineConfig other = (MachineConfig) o; + + if (this.machineConfigEnum != Known.MACHINE_CONFIG_UNSPECIFIED + && other.machineConfigEnum != Known.MACHINE_CONFIG_UNSPECIFIED) { + return this.machineConfigEnum == other.machineConfigEnum; + } else if (this.machineConfigEnum == Known.MACHINE_CONFIG_UNSPECIFIED + && other.machineConfigEnum == Known.MACHINE_CONFIG_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.machineConfigEnum != Known.MACHINE_CONFIG_UNSPECIFIED) { + return this.machineConfigEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.machineConfigEnum; + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Metadata.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Metadata.java new file mode 100644 index 0000000..193bb8f --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/Metadata.java @@ -0,0 +1,87 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Map; +import java.util.Optional; + +/** Metadata for a chunk. */ +@AutoValue +@JsonDeserialize(builder = Metadata.Builder.class) +public abstract class Metadata extends JsonSerializable { + /** + * Optional. Attributes attached to the data. The keys have semantic conventions and the consumers + * of the attributes should know how to deserialize the value bytes based on the keys. + */ + @JsonProperty("attributes") + public abstract Optional> attributes(); + + /** Instantiates a builder for Metadata. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_Metadata.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for Metadata. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `Metadata.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_Metadata.Builder(); + } + + /** + * Setter for attributes. + * + *

attributes: Optional. Attributes attached to the data. The keys have semantic conventions + * and the consumers of the attributes should know how to deserialize the value bytes based on + * the keys. + */ + @JsonProperty("attributes") + public abstract Builder attributes(Map attributes); + + @ExcludeFromGeneratedCoverageReport + abstract Builder attributes(Optional> attributes); + + /** Clears the value of attributes field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAttributes() { + return attributes(Optional.empty()); + } + + public abstract Metadata build(); + } + + /** Deserializes a JSON string to a Metadata object. */ + @ExcludeFromGeneratedCoverageReport + public static Metadata fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, Metadata.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironment.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironment.java new file mode 100644 index 0000000..20ca691 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironment.java @@ -0,0 +1,304 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.time.Duration; +import java.time.Instant; +import java.util.Optional; + +/** A sandbox environment. */ +@AutoValue +@JsonDeserialize(builder = SandboxEnvironment.Builder.class) +public abstract class SandboxEnvironment extends JsonSerializable { + /** Expiration time of the sandbox environment. */ + @JsonProperty("expireTime") + public abstract Optional expireTime(); + + /** Output only. The connection information of the SandboxEnvironment. */ + @JsonProperty("connectionInfo") + public abstract Optional connectionInfo(); + + /** Output only. The timestamp when this SandboxEnvironment was created. */ + @JsonProperty("createTime") + public abstract Optional createTime(); + + /** Required. The display name of the SandboxEnvironment. */ + @JsonProperty("displayName") + public abstract Optional displayName(); + + /** Identifier. The name of the SandboxEnvironment. */ + @JsonProperty("name") + public abstract Optional name(); + + /** Optional. The configuration of the SandboxEnvironment. */ + @JsonProperty("spec") + public abstract Optional spec(); + + /** Output only. The runtime state of the SandboxEnvironment. */ + @JsonProperty("state") + public abstract Optional state(); + + /** + * Optional. Input only. The TTL for the sandbox environment. The expiration time is computed: now + * + TTL. + */ + @JsonProperty("ttl") + public abstract Optional ttl(); + + /** Output only. The timestamp when this SandboxEnvironment was most recently updated. */ + @JsonProperty("updateTime") + public abstract Optional updateTime(); + + /** Instantiates a builder for SandboxEnvironment. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_SandboxEnvironment.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for SandboxEnvironment. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `SandboxEnvironment.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_SandboxEnvironment.Builder(); + } + + /** + * Setter for expireTime. + * + *

expireTime: Expiration time of the sandbox environment. + */ + @JsonProperty("expireTime") + public abstract Builder expireTime(Instant expireTime); + + @ExcludeFromGeneratedCoverageReport + abstract Builder expireTime(Optional expireTime); + + /** Clears the value of expireTime field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearExpireTime() { + return expireTime(Optional.empty()); + } + + /** + * Setter for connectionInfo. + * + *

connectionInfo: Output only. The connection information of the SandboxEnvironment. + */ + @JsonProperty("connectionInfo") + public abstract Builder connectionInfo(SandboxEnvironmentConnectionInfo connectionInfo); + + /** + * Setter for connectionInfo builder. + * + *

connectionInfo: Output only. The connection information of the SandboxEnvironment. + */ + @CanIgnoreReturnValue + public Builder connectionInfo(SandboxEnvironmentConnectionInfo.Builder connectionInfoBuilder) { + return connectionInfo(connectionInfoBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder connectionInfo(Optional connectionInfo); + + /** Clears the value of connectionInfo field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearConnectionInfo() { + return connectionInfo(Optional.empty()); + } + + /** + * Setter for createTime. + * + *

createTime: Output only. The timestamp when this SandboxEnvironment was created. + */ + @JsonProperty("createTime") + public abstract Builder createTime(Instant createTime); + + @ExcludeFromGeneratedCoverageReport + abstract Builder createTime(Optional createTime); + + /** Clears the value of createTime field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCreateTime() { + return createTime(Optional.empty()); + } + + /** + * Setter for displayName. + * + *

displayName: Required. The display name of the SandboxEnvironment. + */ + @JsonProperty("displayName") + public abstract Builder displayName(String displayName); + + @ExcludeFromGeneratedCoverageReport + abstract Builder displayName(Optional displayName); + + /** Clears the value of displayName field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDisplayName() { + return displayName(Optional.empty()); + } + + /** + * Setter for name. + * + *

name: Identifier. The name of the SandboxEnvironment. + */ + @JsonProperty("name") + public abstract Builder name(String name); + + @ExcludeFromGeneratedCoverageReport + abstract Builder name(Optional name); + + /** Clears the value of name field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearName() { + return name(Optional.empty()); + } + + /** + * Setter for spec. + * + *

spec: Optional. The configuration of the SandboxEnvironment. + */ + @JsonProperty("spec") + public abstract Builder spec(SandboxEnvironmentSpec spec); + + /** + * Setter for spec builder. + * + *

spec: Optional. The configuration of the SandboxEnvironment. + */ + @CanIgnoreReturnValue + public Builder spec(SandboxEnvironmentSpec.Builder specBuilder) { + return spec(specBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder spec(Optional spec); + + /** Clears the value of spec field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSpec() { + return spec(Optional.empty()); + } + + /** + * Setter for state. + * + *

state: Output only. The runtime state of the SandboxEnvironment. + */ + @JsonProperty("state") + public abstract Builder state(State state); + + @ExcludeFromGeneratedCoverageReport + abstract Builder state(Optional state); + + /** Clears the value of state field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearState() { + return state(Optional.empty()); + } + + /** + * Setter for state given a known enum. + * + *

state: Output only. The runtime state of the SandboxEnvironment. + */ + @CanIgnoreReturnValue + public Builder state(State.Known knownType) { + return state(new State(knownType)); + } + + /** + * Setter for state given a string. + * + *

state: Output only. The runtime state of the SandboxEnvironment. + */ + @CanIgnoreReturnValue + public Builder state(String state) { + return state(new State(state)); + } + + /** + * Setter for ttl. + * + *

ttl: Optional. Input only. The TTL for the sandbox environment. The expiration time is + * computed: now + TTL. + */ + @JsonProperty("ttl") + public abstract Builder ttl(Duration ttl); + + @ExcludeFromGeneratedCoverageReport + abstract Builder ttl(Optional ttl); + + /** Clears the value of ttl field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearTtl() { + return ttl(Optional.empty()); + } + + /** + * Setter for updateTime. + * + *

updateTime: Output only. The timestamp when this SandboxEnvironment was most recently + * updated. + */ + @JsonProperty("updateTime") + public abstract Builder updateTime(Instant updateTime); + + @ExcludeFromGeneratedCoverageReport + abstract Builder updateTime(Optional updateTime); + + /** Clears the value of updateTime field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearUpdateTime() { + return updateTime(Optional.empty()); + } + + public abstract SandboxEnvironment build(); + } + + /** Deserializes a JSON string to a SandboxEnvironment object. */ + @ExcludeFromGeneratedCoverageReport + public static SandboxEnvironment fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, SandboxEnvironment.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentConnectionInfo.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentConnectionInfo.java new file mode 100644 index 0000000..406fe68 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentConnectionInfo.java @@ -0,0 +1,128 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** The connection information of the SandboxEnvironment. */ +@AutoValue +@JsonDeserialize(builder = SandboxEnvironmentConnectionInfo.Builder.class) +public abstract class SandboxEnvironmentConnectionInfo extends JsonSerializable { + /** Output only. The hostname of the load balancer. */ + @JsonProperty("loadBalancerHostname") + public abstract Optional loadBalancerHostname(); + + /** Output only. The IP address of the load balancer. */ + @JsonProperty("loadBalancerIp") + public abstract Optional loadBalancerIp(); + + /** Output only. The internal IP address of the SandboxEnvironment. */ + @JsonProperty("sandboxInternalIp") + public abstract Optional sandboxInternalIp(); + + /** Instantiates a builder for SandboxEnvironmentConnectionInfo. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_SandboxEnvironmentConnectionInfo.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for SandboxEnvironmentConnectionInfo. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `SandboxEnvironmentConnectionInfo.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_SandboxEnvironmentConnectionInfo.Builder(); + } + + /** + * Setter for loadBalancerHostname. + * + *

loadBalancerHostname: Output only. The hostname of the load balancer. + */ + @JsonProperty("loadBalancerHostname") + public abstract Builder loadBalancerHostname(String loadBalancerHostname); + + @ExcludeFromGeneratedCoverageReport + abstract Builder loadBalancerHostname(Optional loadBalancerHostname); + + /** Clears the value of loadBalancerHostname field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearLoadBalancerHostname() { + return loadBalancerHostname(Optional.empty()); + } + + /** + * Setter for loadBalancerIp. + * + *

loadBalancerIp: Output only. The IP address of the load balancer. + */ + @JsonProperty("loadBalancerIp") + public abstract Builder loadBalancerIp(String loadBalancerIp); + + @ExcludeFromGeneratedCoverageReport + abstract Builder loadBalancerIp(Optional loadBalancerIp); + + /** Clears the value of loadBalancerIp field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearLoadBalancerIp() { + return loadBalancerIp(Optional.empty()); + } + + /** + * Setter for sandboxInternalIp. + * + *

sandboxInternalIp: Output only. The internal IP address of the SandboxEnvironment. + */ + @JsonProperty("sandboxInternalIp") + public abstract Builder sandboxInternalIp(String sandboxInternalIp); + + @ExcludeFromGeneratedCoverageReport + abstract Builder sandboxInternalIp(Optional sandboxInternalIp); + + /** Clears the value of sandboxInternalIp field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSandboxInternalIp() { + return sandboxInternalIp(Optional.empty()); + } + + public abstract SandboxEnvironmentConnectionInfo build(); + } + + /** Deserializes a JSON string to a SandboxEnvironmentConnectionInfo object. */ + @ExcludeFromGeneratedCoverageReport + public static SandboxEnvironmentConnectionInfo fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, SandboxEnvironmentConnectionInfo.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpec.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpec.java new file mode 100644 index 0000000..f98a7b9 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpec.java @@ -0,0 +1,130 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** The specification of a sandbox environment. */ +@AutoValue +@JsonDeserialize(builder = SandboxEnvironmentSpec.Builder.class) +public abstract class SandboxEnvironmentSpec extends JsonSerializable { + /** Optional. The code execution environment. */ + @JsonProperty("codeExecutionEnvironment") + public abstract Optional + codeExecutionEnvironment(); + + /** Optional. The computer use environment. */ + @JsonProperty("computerUseEnvironment") + public abstract Optional computerUseEnvironment(); + + /** Instantiates a builder for SandboxEnvironmentSpec. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_SandboxEnvironmentSpec.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for SandboxEnvironmentSpec. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `SandboxEnvironmentSpec.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_SandboxEnvironmentSpec.Builder(); + } + + /** + * Setter for codeExecutionEnvironment. + * + *

codeExecutionEnvironment: Optional. The code execution environment. + */ + @JsonProperty("codeExecutionEnvironment") + public abstract Builder codeExecutionEnvironment( + SandboxEnvironmentSpecCodeExecutionEnvironment codeExecutionEnvironment); + + /** + * Setter for codeExecutionEnvironment builder. + * + *

codeExecutionEnvironment: Optional. The code execution environment. + */ + @CanIgnoreReturnValue + public Builder codeExecutionEnvironment( + SandboxEnvironmentSpecCodeExecutionEnvironment.Builder codeExecutionEnvironmentBuilder) { + return codeExecutionEnvironment(codeExecutionEnvironmentBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder codeExecutionEnvironment( + Optional codeExecutionEnvironment); + + /** Clears the value of codeExecutionEnvironment field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCodeExecutionEnvironment() { + return codeExecutionEnvironment(Optional.empty()); + } + + /** + * Setter for computerUseEnvironment. + * + *

computerUseEnvironment: Optional. The computer use environment. + */ + @JsonProperty("computerUseEnvironment") + public abstract Builder computerUseEnvironment( + SandboxEnvironmentSpecComputerUseEnvironment computerUseEnvironment); + + /** + * Setter for computerUseEnvironment builder. + * + *

computerUseEnvironment: Optional. The computer use environment. + */ + @CanIgnoreReturnValue + public Builder computerUseEnvironment( + SandboxEnvironmentSpecComputerUseEnvironment.Builder computerUseEnvironmentBuilder) { + return computerUseEnvironment(computerUseEnvironmentBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder computerUseEnvironment( + Optional computerUseEnvironment); + + /** Clears the value of computerUseEnvironment field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearComputerUseEnvironment() { + return computerUseEnvironment(Optional.empty()); + } + + public abstract SandboxEnvironmentSpec build(); + } + + /** Deserializes a JSON string to a SandboxEnvironmentSpec object. */ + @ExcludeFromGeneratedCoverageReport + public static SandboxEnvironmentSpec fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, SandboxEnvironmentSpec.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpecCodeExecutionEnvironment.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpecCodeExecutionEnvironment.java new file mode 100644 index 0000000..6e9733c --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpecCodeExecutionEnvironment.java @@ -0,0 +1,147 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** The code execution environment with customized settings. */ +@AutoValue +@JsonDeserialize(builder = SandboxEnvironmentSpecCodeExecutionEnvironment.Builder.class) +public abstract class SandboxEnvironmentSpecCodeExecutionEnvironment extends JsonSerializable { + /** The coding language supported in this environment. */ + @JsonProperty("codeLanguage") + public abstract Optional codeLanguage(); + + /** The machine config of the code execution environment. */ + @JsonProperty("machineConfig") + public abstract Optional machineConfig(); + + /** Instantiates a builder for SandboxEnvironmentSpecCodeExecutionEnvironment. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_SandboxEnvironmentSpecCodeExecutionEnvironment.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for SandboxEnvironmentSpecCodeExecutionEnvironment. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `SandboxEnvironmentSpecCodeExecutionEnvironment.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_SandboxEnvironmentSpecCodeExecutionEnvironment.Builder(); + } + + /** + * Setter for codeLanguage. + * + *

codeLanguage: The coding language supported in this environment. + */ + @JsonProperty("codeLanguage") + public abstract Builder codeLanguage(Language codeLanguage); + + @ExcludeFromGeneratedCoverageReport + abstract Builder codeLanguage(Optional codeLanguage); + + /** Clears the value of codeLanguage field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCodeLanguage() { + return codeLanguage(Optional.empty()); + } + + /** + * Setter for codeLanguage given a known enum. + * + *

codeLanguage: The coding language supported in this environment. + */ + @CanIgnoreReturnValue + public Builder codeLanguage(Language.Known knownType) { + return codeLanguage(new Language(knownType)); + } + + /** + * Setter for codeLanguage given a string. + * + *

codeLanguage: The coding language supported in this environment. + */ + @CanIgnoreReturnValue + public Builder codeLanguage(String codeLanguage) { + return codeLanguage(new Language(codeLanguage)); + } + + /** + * Setter for machineConfig. + * + *

machineConfig: The machine config of the code execution environment. + */ + @JsonProperty("machineConfig") + public abstract Builder machineConfig(MachineConfig machineConfig); + + @ExcludeFromGeneratedCoverageReport + abstract Builder machineConfig(Optional machineConfig); + + /** Clears the value of machineConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMachineConfig() { + return machineConfig(Optional.empty()); + } + + /** + * Setter for machineConfig given a known enum. + * + *

machineConfig: The machine config of the code execution environment. + */ + @CanIgnoreReturnValue + public Builder machineConfig(MachineConfig.Known knownType) { + return machineConfig(new MachineConfig(knownType)); + } + + /** + * Setter for machineConfig given a string. + * + *

machineConfig: The machine config of the code execution environment. + */ + @CanIgnoreReturnValue + public Builder machineConfig(String machineConfig) { + return machineConfig(new MachineConfig(machineConfig)); + } + + public abstract SandboxEnvironmentSpecCodeExecutionEnvironment build(); + } + + /** Deserializes a JSON string to a SandboxEnvironmentSpecCodeExecutionEnvironment object. */ + @ExcludeFromGeneratedCoverageReport + public static SandboxEnvironmentSpecCodeExecutionEnvironment fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, SandboxEnvironmentSpecCodeExecutionEnvironment.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpecComputerUseEnvironment.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpecComputerUseEnvironment.java new file mode 100644 index 0000000..f6857fe --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/SandboxEnvironmentSpecComputerUseEnvironment.java @@ -0,0 +1,60 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.genai.JsonSerializable; + +/** The computer use environment with customized settings. */ +@AutoValue +@JsonDeserialize(builder = SandboxEnvironmentSpecComputerUseEnvironment.Builder.class) +public abstract class SandboxEnvironmentSpecComputerUseEnvironment extends JsonSerializable { + /** Instantiates a builder for SandboxEnvironmentSpecComputerUseEnvironment. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_SandboxEnvironmentSpecComputerUseEnvironment.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for SandboxEnvironmentSpecComputerUseEnvironment. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `SandboxEnvironmentSpecComputerUseEnvironment.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_SandboxEnvironmentSpecComputerUseEnvironment.Builder(); + } + + public abstract SandboxEnvironmentSpecComputerUseEnvironment build(); + } + + /** Deserializes a JSON string to a SandboxEnvironmentSpecComputerUseEnvironment object. */ + @ExcludeFromGeneratedCoverageReport + public static SandboxEnvironmentSpecComputerUseEnvironment fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, SandboxEnvironmentSpecComputerUseEnvironment.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/State.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/State.java new file mode 100644 index 0000000..3c76786 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/State.java @@ -0,0 +1,119 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.cloud.vertexai.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.base.Ascii; +import java.util.Objects; + +/** Output only. The runtime state of the SandboxEnvironment. */ +public class State { + + /** Enum representing the known values for State. */ + public enum Known { + /** The default value. This value is unused. */ + STATE_UNSPECIFIED, + + /** Runtime resources are being allocated for the sandbox environment. */ + STATE_PROVISIONING, + + /** Sandbox runtime is ready for serving. */ + STATE_RUNNING, + + /** Sandbox runtime is halted, performing tear down tasks. */ + STATE_DEPROVISIONING, + + /** Sandbox has terminated with underlying runtime failure. */ + STATE_TERMINATED, + + /** Sandbox runtime has been deleted. */ + STATE_DELETED + } + + private Known stateEnum; + private final String value; + + @JsonCreator + public State(String value) { + this.value = value; + for (Known stateEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(stateEnum.toString(), value)) { + this.stateEnum = stateEnum; + break; + } + } + if (this.stateEnum == null) { + this.stateEnum = Known.STATE_UNSPECIFIED; + } + } + + public State(Known knownValue) { + this.stateEnum = knownValue; + this.value = knownValue.toString(); + } + + @ExcludeFromGeneratedCoverageReport + @Override + @JsonValue + public String toString() { + return this.value; + } + + @ExcludeFromGeneratedCoverageReport + @SuppressWarnings("PatternMatchingInstanceof") + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null) { + return false; + } + + if (!(o instanceof State)) { + return false; + } + + State other = (State) o; + + if (this.stateEnum != Known.STATE_UNSPECIFIED && other.stateEnum != Known.STATE_UNSPECIFIED) { + return this.stateEnum == other.stateEnum; + } else if (this.stateEnum == Known.STATE_UNSPECIFIED + && other.stateEnum == Known.STATE_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.stateEnum != Known.STATE_UNSPECIFIED) { + return this.stateEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.stateEnum; + } +} diff --git a/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/genai/AgentEnginesSandboxesTest.java b/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/genai/AgentEnginesSandboxesTest.java new file mode 100644 index 0000000..e1141e0 --- /dev/null +++ b/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/genai/AgentEnginesSandboxesTest.java @@ -0,0 +1,158 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.vertexai.genai; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import com.google.cloud.vertexai.genai.types.AgentEngineSandboxOperation; +import com.google.cloud.vertexai.genai.types.Chunk; +import com.google.cloud.vertexai.genai.types.DeleteAgentEngineSandboxOperation; +import com.google.cloud.vertexai.genai.types.ExecuteSandboxEnvironmentResponse; +import com.google.cloud.vertexai.genai.types.Metadata; +import com.google.cloud.vertexai.genai.types.ListAgentEngineSandboxesResponse; +import com.google.cloud.vertexai.genai.types.SandboxEnvironment; +import com.google.cloud.vertexai.genai.types.SandboxEnvironmentSpec; +import com.google.cloud.vertexai.genai.types.SandboxEnvironmentSpecCodeExecutionEnvironment; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.genai.JsonSerializable; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.junit.jupiter.api.extension.ExtendWith; + +@EnabledIfEnvironmentVariable( + named = "GOOGLE_GENAI_REPLAYS_DIRECTORY", + matches = ".*genai/replays.*") +@ExtendWith(EnvironmentVariablesMockingExtension.class) +public class AgentEnginesSandboxesTest { + + @Test + public void testPrivateCreateAgentEngineSandbox() throws Exception { + Client client = + TestUtils.createClient(true, "ae_sandboxes_private_create/test_private_create.vertex.json"); + + AgentEngineSandboxOperation operation = + client.agentEngines.sandboxes.privateCreate( + "projects/964831358985/locations/us-central1/reasoningEngines/2886612747586371584", + SandboxEnvironmentSpec.builder() + .codeExecutionEnvironment( + SandboxEnvironmentSpecCodeExecutionEnvironment.builder() + .machineConfig("MACHINE_CONFIG_VCPU4_RAM4GIB") + .build()) + .build(), + null); + + assertNotNull(operation.name()); + } + + @Test + public void testPrivateListAgentEngineSandbox() throws Exception { + Client client = + TestUtils.createClient(true, "ae_sandboxes_private_list/test_private_list.vertex.json"); + + ListAgentEngineSandboxesResponse response = + client.agentEngines.sandboxes.privateList("reasoningEngines/2886612747586371584", null); + + assertNotNull(response.sandboxEnvironments()); + assertFalse(response.sandboxEnvironments().get().isEmpty()); + } + + @Test + public void testPrivateGetAgentEngineSandbox() throws Exception { + Client client = + TestUtils.createClient(true, "ae_sandboxes_private_get/test_private_get.vertex.json"); + + SandboxEnvironment response = + client.agentEngines.sandboxes.privateGet( + "projects/964831358985/locations/us-central1/reasoningEngines/2886612747586371584/sandboxEnvironments/3186171392039059456", + null); + + assertNotNull(response.name()); + } + + @Test + public void testPrivateGetAgentEngineSandboxOperation() throws Exception { + Client client = + TestUtils.createClient( + true, + "ae_sandboxes_private_get_sandbox_operation/test_private_get_operation.vertex.json"); + + AgentEngineSandboxOperation operation = + client.agentEngines.sandboxes.privateGetSandboxOperation( + "projects/964831358985/locations/us-central1/operations/4799455193970245632", null); + + assertNotNull(operation.name()); + } + + @Test + public void testPrivateExecuteCode() throws Exception { + Client client = + TestUtils.createClient( + true, "ae_sandboxes_private_execute_code/test_private_execute_code.vertex.json"); + + String code = + "\nwith open(\"test.txt\", \"r\") as input:\n" + + " with open(\"output.txt\", \"w\") as output_txt:\n" + + " for line in input:\n" + + " output_txt.write(line)\n"; + + String jsonWithSpace = String.format("{\"code\": %s}", JsonSerializable.toJsonString(code)); + + Chunk chunk1 = + Chunk.builder() + .data(jsonWithSpace.getBytes(StandardCharsets.UTF_8)) + .mimeType("application/json") + .build(); + + Chunk chunk2 = + Chunk.builder() + .data("Hello, world!".getBytes(StandardCharsets.UTF_8)) + .metadata( + Metadata.builder() + .attributes( + ImmutableMap.of("fileName", "test.txt".getBytes(StandardCharsets.UTF_8))) + .build()) + .mimeType("text/plain") + .build(); + + List inputs = ImmutableList.of(chunk1, chunk2); + + ExecuteSandboxEnvironmentResponse response = + client.agentEngines.sandboxes.privateExecuteCode( + "reasoningEngines/2886612747586371584/sandboxEnvironments/6068475153556176896", + inputs, + null); + + assertNotNull(response.outputs()); + } + + @Test + public void testDeleteAgentEngineSandbox() throws Exception { + Client client = + TestUtils.createClient(true, "ae_sandboxes_private_delete/test_private_delete.vertex.json"); + + DeleteAgentEngineSandboxOperation operation = + client.agentEngines.sandboxes.privateDelete( + "reasoningEngines/2886612747586371584/sandboxEnvironments/6068475153556176896", null); + + assertNotNull(operation.name()); + } +}