Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>com.google.genai</groupId>
<artifactId>google-genai</artifactId>
<version>1.55.0</version>
<version>1.65.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
141 changes: 65 additions & 76 deletions src/main/java/com/google/cloud/agentplatform/AgentEngines.java

Large diffs are not rendered by default.

161 changes: 77 additions & 84 deletions src/main/java/com/google/cloud/agentplatform/Memories.java

Large diffs are not rendered by default.

27 changes: 12 additions & 15 deletions src/main/java/com/google/cloud/agentplatform/MemoryRevisions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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;
Expand All @@ -48,7 +47,7 @@ public MemoryRevisions(ApiClient apiClient) {
@ExcludeFromGeneratedCoverageReport
ObjectNode getAgentEngineMemoryRevisionRequestParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -62,7 +61,7 @@ ObjectNode getAgentEngineMemoryRevisionRequestParametersToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode listAgentEngineMemoryRevisionsConfigToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();

if (Common.getValueByPath(fromObject, new String[] {"pageSize"}) != null) {
Common.setValueByPath(
Expand Down Expand Up @@ -91,7 +90,7 @@ ObjectNode listAgentEngineMemoryRevisionsConfigToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode listAgentEngineMemoryRevisionsRequestParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -102,8 +101,7 @@ ObjectNode listAgentEngineMemoryRevisionsRequestParametersToVertex(
if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
JsonNode unused =
listAgentEngineMemoryRevisionsConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"config"})),
Common.toJsonNode(Common.getValueByPath(fromObject, new String[] {"config"})),
toObject);
}

Expand All @@ -122,7 +120,7 @@ BuiltRequest buildRequestForGet(String name, GetAgentEngineMemoryRevisionConfig
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -148,7 +146,7 @@ BuiltRequest buildRequestForGet(String name, GetAgentEngineMemoryRevisionConfig
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -162,15 +160,15 @@ MemoryRevision processResponseForGet(
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(responseNode, MemoryRevision.class);
return Common.fromJsonNode(responseNode, MemoryRevision.class);
}

public MemoryRevision get(String name, GetAgentEngineMemoryRevisionConfig config) {
Expand All @@ -196,7 +194,7 @@ BuiltRequest buildRequestForPrivateList(
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -222,7 +220,7 @@ BuiltRequest buildRequestForPrivateList(
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -236,16 +234,15 @@ ListAgentEngineMemoryRevisionsResponse processResponseForPrivateList(
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(
responseNode, ListAgentEngineMemoryRevisionsResponse.class);
return Common.fromJsonNode(responseNode, ListAgentEngineMemoryRevisionsResponse.class);
}

public ListAgentEngineMemoryRevisionsResponse privateList(
Expand Down
63 changes: 29 additions & 34 deletions src/main/java/com/google/cloud/agentplatform/SandboxSnapshots.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
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;
Expand All @@ -56,7 +55,7 @@ public SandboxSnapshots(ApiClient apiClient) {
@ExcludeFromGeneratedCoverageReport
ObjectNode createAgentEngineSandboxSnapshotConfigToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();

if (Common.getValueByPath(fromObject, new String[] {"displayName"}) != null) {
Common.setValueByPath(
Expand Down Expand Up @@ -85,7 +84,7 @@ ObjectNode createAgentEngineSandboxSnapshotConfigToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode createSandboxEnvironmentSnapshotRequestParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"sourceSandboxEnvironmentName"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -96,8 +95,7 @@ ObjectNode createSandboxEnvironmentSnapshotRequestParametersToVertex(
if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
JsonNode unused =
createAgentEngineSandboxSnapshotConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"config"})),
Common.toJsonNode(Common.getValueByPath(fromObject, new String[] {"config"})),
toObject);
}

Expand All @@ -107,7 +105,7 @@ ObjectNode createSandboxEnvironmentSnapshotRequestParametersToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode deleteSandboxEnvironmentSnapshotRequestParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -121,7 +119,7 @@ ObjectNode deleteSandboxEnvironmentSnapshotRequestParametersToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode getAgentEngineSandboxSnapshotOperationParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"operationName"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -135,7 +133,7 @@ ObjectNode getAgentEngineSandboxSnapshotOperationParametersToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode getSandboxEnvironmentSnapshotRequestParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -149,7 +147,7 @@ ObjectNode getSandboxEnvironmentSnapshotRequestParametersToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode listSandboxEnvironmentSnapshotsConfigToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();

if (Common.getValueByPath(fromObject, new String[] {"pageSize"}) != null) {
Common.setValueByPath(
Expand Down Expand Up @@ -178,7 +176,7 @@ ObjectNode listSandboxEnvironmentSnapshotsConfigToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode listSandboxEnvironmentSnapshotsRequestParametersToVertex(
JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
ObjectNode toObject = Common.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -189,8 +187,7 @@ ObjectNode listSandboxEnvironmentSnapshotsRequestParametersToVertex(
if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
JsonNode unused =
listSandboxEnvironmentSnapshotsConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"config"})),
Common.toJsonNode(Common.getValueByPath(fromObject, new String[] {"config"})),
toObject);
}

Expand All @@ -210,7 +207,7 @@ BuiltRequest buildRequestForPrivateCreate(
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -236,7 +233,7 @@ BuiltRequest buildRequestForPrivateCreate(
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -250,15 +247,15 @@ AgentEngineSandboxSnapshotOperation processResponseForPrivateCreate(
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(responseNode, AgentEngineSandboxSnapshotOperation.class);
return Common.fromJsonNode(responseNode, AgentEngineSandboxSnapshotOperation.class);
}

public AgentEngineSandboxSnapshotOperation privateCreate(
Expand All @@ -285,7 +282,7 @@ BuiltRequest buildRequestForPrivateDelete(
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -311,7 +308,7 @@ BuiltRequest buildRequestForPrivateDelete(
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -325,16 +322,15 @@ DeleteSandboxEnvironmentSnapshotOperation processResponseForPrivateDelete(
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(
responseNode, DeleteSandboxEnvironmentSnapshotOperation.class);
return Common.fromJsonNode(responseNode, DeleteSandboxEnvironmentSnapshotOperation.class);
}

public DeleteSandboxEnvironmentSnapshotOperation privateDelete(
Expand All @@ -360,7 +356,7 @@ BuiltRequest buildRequestForPrivateGet(String name, GetSandboxEnvironmentSnapsho
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -386,7 +382,7 @@ BuiltRequest buildRequestForPrivateGet(String name, GetSandboxEnvironmentSnapsho
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -400,15 +396,15 @@ SandboxEnvironmentSnapshot processResponseForPrivateGet(
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(responseNode, SandboxEnvironmentSnapshot.class);
return Common.fromJsonNode(responseNode, SandboxEnvironmentSnapshot.class);
}

public SandboxEnvironmentSnapshot privateGet(
Expand All @@ -435,7 +431,7 @@ BuiltRequest buildRequestForPrivateList(
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -461,7 +457,7 @@ BuiltRequest buildRequestForPrivateList(
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -475,16 +471,15 @@ ListSandboxEnvironmentSnapshotsResponse processResponseForPrivateList(
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(
responseNode, ListSandboxEnvironmentSnapshotsResponse.class);
return Common.fromJsonNode(responseNode, ListSandboxEnvironmentSnapshotsResponse.class);
}

public ListSandboxEnvironmentSnapshotsResponse privateList(
Expand All @@ -511,7 +506,7 @@ BuiltRequest buildRequestForGetSandboxSnapshotOperation(
if (!Common.isZero(config)) {
parameterBuilder.config(config);
}
JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
JsonNode parameterNode = Common.toJsonNode(parameterBuilder.build());

ObjectNode body;
String path;
Expand All @@ -537,7 +532,7 @@ BuiltRequest buildRequestForGetSandboxSnapshotOperation(
requestHttpOptions = config.httpOptions();
}

return new BuiltRequest(path, JsonSerializable.toJsonString(body), requestHttpOptions);
return new BuiltRequest(path, Common.toJsonString(body), requestHttpOptions);
}

/** A shared processResponse function for both sync and async methods. */
Expand All @@ -551,15 +546,15 @@ AgentEngineSandboxSnapshotOperation processResponseForGetSandboxSnapshotOperatio
throw new GenAiIOException("Failed to read HTTP response.", e);
}

JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
JsonNode responseNode = Common.stringToJsonNode(responseString);

if (!this.apiClient.vertexAI()) {
throw new UnsupportedOperationException(
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini"
+ " Developer API mode.");
}

return JsonSerializable.fromJsonNode(responseNode, AgentEngineSandboxSnapshotOperation.class);
return Common.fromJsonNode(responseNode, AgentEngineSandboxSnapshotOperation.class);
}

public AgentEngineSandboxSnapshotOperation getSandboxSnapshotOperation(
Expand Down
Loading
Loading