diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncMemories.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncMemories.java index 4245a40..bccf1ce 100644 --- a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncMemories.java +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncMemories.java @@ -51,6 +51,7 @@ /** Async module of {@link Memories} */ public final class AsyncMemories { + public final AsyncMemoryRevisions revisions; Memories memories; ApiClient apiClient; @@ -58,6 +59,8 @@ public final class AsyncMemories { public AsyncMemories(ApiClient apiClient) { this.apiClient = apiClient; this.memories = new Memories(apiClient); + + this.revisions = new AsyncMemoryRevisions(apiClient); } CompletableFuture privateCreate( diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncMemoryRevisions.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncMemoryRevisions.java new file mode 100644 index 0000000..f7c58e0 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/AsyncMemoryRevisions.java @@ -0,0 +1,68 @@ +/* + * 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.GetAgentEngineMemoryRevisionConfig; +import com.google.cloud.vertexai.genai.types.ListAgentEngineMemoryRevisionsConfig; +import com.google.cloud.vertexai.genai.types.ListAgentEngineMemoryRevisionsResponse; +import com.google.cloud.vertexai.genai.types.MemoryRevision; +import com.google.genai.ApiClient; +import com.google.genai.ApiResponse; +import com.google.genai.Common.BuiltRequest; +import java.util.concurrent.CompletableFuture; + +/** Async module of {@link MemoryRevisions} */ +public final class AsyncMemoryRevisions { + + MemoryRevisions memoryRevisions; + ApiClient apiClient; + + public AsyncMemoryRevisions(ApiClient apiClient) { + this.apiClient = apiClient; + this.memoryRevisions = new MemoryRevisions(apiClient); + } + + public CompletableFuture get( + String name, GetAgentEngineMemoryRevisionConfig config) { + + BuiltRequest builtRequest = memoryRevisions.buildRequestForGet(name, config); + return this.apiClient + .asyncRequest("get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions()) + .thenApplyAsync( + response -> { + try (ApiResponse res = response) { + return memoryRevisions.processResponseForGet(res, config); + } + }); + } + + CompletableFuture privateList( + String name, ListAgentEngineMemoryRevisionsConfig config) { + + BuiltRequest builtRequest = memoryRevisions.buildRequestForPrivateList(name, config); + return this.apiClient + .asyncRequest("get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions()) + .thenApplyAsync( + response -> { + try (ApiResponse res = response) { + return memoryRevisions.processResponseForPrivateList(res, config); + } + }); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/Memories.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/Memories.java index 933f961..8f14892 100644 --- a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/Memories.java +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/Memories.java @@ -69,11 +69,13 @@ import okhttp3.ResponseBody; public final class Memories { + public final MemoryRevisions revisions; final ApiClient apiClient; public Memories(ApiClient apiClient) { this.apiClient = apiClient; + this.revisions = new MemoryRevisions(apiClient); } @ExcludeFromGeneratedCoverageReport diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/MemoryRevisions.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/MemoryRevisions.java new file mode 100644 index 0000000..53a43c7 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/MemoryRevisions.java @@ -0,0 +1,257 @@ +/* + * 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.GetAgentEngineMemoryRevisionConfig; +import com.google.cloud.vertexai.genai.types.GetAgentEngineMemoryRevisionRequestParameters; +import com.google.cloud.vertexai.genai.types.ListAgentEngineMemoryRevisionsConfig; +import com.google.cloud.vertexai.genai.types.ListAgentEngineMemoryRevisionsRequestParameters; +import com.google.cloud.vertexai.genai.types.ListAgentEngineMemoryRevisionsResponse; +import com.google.cloud.vertexai.genai.types.MemoryRevision; +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.Optional; +import okhttp3.ResponseBody; + +public final class MemoryRevisions { + + final ApiClient apiClient; + + public MemoryRevisions(ApiClient apiClient) { + this.apiClient = apiClient; + } + + @ExcludeFromGeneratedCoverageReport + ObjectNode getAgentEngineMemoryRevisionRequestParametersToVertex( + 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 listAgentEngineMemoryRevisionsConfigToVertex( + 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 listAgentEngineMemoryRevisionsRequestParametersToVertex( + 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 = + listAgentEngineMemoryRevisionsConfigToVertex( + JsonSerializable.toJsonNode( + Common.getValueByPath(fromObject, new String[] {"config"})), + toObject); + } + + return toObject; + } + + /** A shared buildRequest method for both sync and async methods. */ + BuiltRequest buildRequestForGet(String name, GetAgentEngineMemoryRevisionConfig config) { + + GetAgentEngineMemoryRevisionRequestParameters.Builder parameterBuilder = + GetAgentEngineMemoryRevisionRequestParameters.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 = getAgentEngineMemoryRevisionRequestParametersToVertex(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. */ + MemoryRevision processResponseForGet( + ApiResponse response, GetAgentEngineMemoryRevisionConfig 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, MemoryRevision.class); + } + + public MemoryRevision get(String name, GetAgentEngineMemoryRevisionConfig config) { + BuiltRequest builtRequest = buildRequestForGet(name, config); + + try (ApiResponse response = + this.apiClient.request( + "get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions())) { + return processResponseForGet(response, config); + } + } + + /** A shared buildRequest method for both sync and async methods. */ + BuiltRequest buildRequestForPrivateList( + String name, ListAgentEngineMemoryRevisionsConfig config) { + + ListAgentEngineMemoryRevisionsRequestParameters.Builder parameterBuilder = + ListAgentEngineMemoryRevisionsRequestParameters.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 = listAgentEngineMemoryRevisionsRequestParametersToVertex(parameterNode, null); + path = Common.formatMap("{name}/revisions", 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. */ + ListAgentEngineMemoryRevisionsResponse processResponseForPrivateList( + ApiResponse response, ListAgentEngineMemoryRevisionsConfig 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, ListAgentEngineMemoryRevisionsResponse.class); + } + + public ListAgentEngineMemoryRevisionsResponse privateList( + String name, ListAgentEngineMemoryRevisionsConfig config) { + BuiltRequest builtRequest = buildRequestForPrivateList(name, config); + + try (ApiResponse response = + this.apiClient.request( + "get", builtRequest.path(), builtRequest.body(), builtRequest.httpOptions())) { + return processResponseForPrivateList(response, config); + } + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineMemoryRevisionConfig.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineMemoryRevisionConfig.java new file mode 100644 index 0000000..bc29604 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineMemoryRevisionConfig.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 getting an Agent Engine Memory Revision. */ +@AutoValue +@JsonDeserialize(builder = GetAgentEngineMemoryRevisionConfig.Builder.class) +public abstract class GetAgentEngineMemoryRevisionConfig extends JsonSerializable { + /** Used to override HTTP request options. */ + @JsonProperty("httpOptions") + public abstract Optional httpOptions(); + + /** Instantiates a builder for GetAgentEngineMemoryRevisionConfig. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_GetAgentEngineMemoryRevisionConfig.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for GetAgentEngineMemoryRevisionConfig. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `GetAgentEngineMemoryRevisionConfig.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_GetAgentEngineMemoryRevisionConfig.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 GetAgentEngineMemoryRevisionConfig build(); + } + + /** Deserializes a JSON string to a GetAgentEngineMemoryRevisionConfig object. */ + @ExcludeFromGeneratedCoverageReport + public static GetAgentEngineMemoryRevisionConfig fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, GetAgentEngineMemoryRevisionConfig.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineMemoryRevisionRequestParameters.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineMemoryRevisionRequestParameters.java new file mode 100644 index 0000000..fe338dd --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/GetAgentEngineMemoryRevisionRequestParameters.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 memory revision. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = GetAgentEngineMemoryRevisionRequestParameters.Builder.class) +public abstract class GetAgentEngineMemoryRevisionRequestParameters extends JsonSerializable { + /** Name of the agent engine. */ + @JsonProperty("name") + public abstract Optional name(); + + /** */ + @JsonProperty("config") + public abstract Optional config(); + + /** Instantiates a builder for GetAgentEngineMemoryRevisionRequestParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_GetAgentEngineMemoryRevisionRequestParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for GetAgentEngineMemoryRevisionRequestParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `GetAgentEngineMemoryRevisionRequestParameters.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_GetAgentEngineMemoryRevisionRequestParameters.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(GetAgentEngineMemoryRevisionConfig config); + + /** + * Setter for config builder. + * + *

config: + */ + @CanIgnoreReturnValue + public Builder config(GetAgentEngineMemoryRevisionConfig.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 GetAgentEngineMemoryRevisionRequestParameters build(); + } + + /** Deserializes a JSON string to a GetAgentEngineMemoryRevisionRequestParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static GetAgentEngineMemoryRevisionRequestParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, GetAgentEngineMemoryRevisionRequestParameters.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/IntermediateExtractedMemory.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/IntermediateExtractedMemory.java new file mode 100644 index 0000000..c413cde --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/IntermediateExtractedMemory.java @@ -0,0 +1,81 @@ +/* + * 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; + +/** An extracted memory that is the intermediate result before consolidation. */ +@AutoValue +@JsonDeserialize(builder = IntermediateExtractedMemory.Builder.class) +public abstract class IntermediateExtractedMemory extends JsonSerializable { + /** Output only. The fact of the extracted memory. */ + @JsonProperty("fact") + public abstract Optional fact(); + + /** Instantiates a builder for IntermediateExtractedMemory. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_IntermediateExtractedMemory.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for IntermediateExtractedMemory. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `IntermediateExtractedMemory.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_IntermediateExtractedMemory.Builder(); + } + + /** + * Setter for fact. + * + *

fact: Output only. The fact of the extracted memory. + */ + @JsonProperty("fact") + public abstract Builder fact(String fact); + + @ExcludeFromGeneratedCoverageReport + abstract Builder fact(Optional fact); + + /** Clears the value of fact field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearFact() { + return fact(Optional.empty()); + } + + public abstract IntermediateExtractedMemory build(); + } + + /** Deserializes a JSON string to a IntermediateExtractedMemory object. */ + @ExcludeFromGeneratedCoverageReport + public static IntermediateExtractedMemory fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, IntermediateExtractedMemory.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsConfig.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsConfig.java new file mode 100644 index 0000000..2323be0 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsConfig.java @@ -0,0 +1,155 @@ +/* + * 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 memory revisions. */ +@AutoValue +@JsonDeserialize(builder = ListAgentEngineMemoryRevisionsConfig.Builder.class) +public abstract class ListAgentEngineMemoryRevisionsConfig 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 ListAgentEngineMemoryRevisionsConfig. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ListAgentEngineMemoryRevisionsConfig.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ListAgentEngineMemoryRevisionsConfig. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ListAgentEngineMemoryRevisionsConfig.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ListAgentEngineMemoryRevisionsConfig.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 ListAgentEngineMemoryRevisionsConfig build(); + } + + /** Deserializes a JSON string to a ListAgentEngineMemoryRevisionsConfig object. */ + @ExcludeFromGeneratedCoverageReport + public static ListAgentEngineMemoryRevisionsConfig fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ListAgentEngineMemoryRevisionsConfig.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsRequestParameters.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsRequestParameters.java new file mode 100644 index 0000000..19667b7 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsRequestParameters.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 memory revisions. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = ListAgentEngineMemoryRevisionsRequestParameters.Builder.class) +public abstract class ListAgentEngineMemoryRevisionsRequestParameters extends JsonSerializable { + /** Name of the Agent Engine memory */ + @JsonProperty("name") + public abstract Optional name(); + + /** */ + @JsonProperty("config") + public abstract Optional config(); + + /** Instantiates a builder for ListAgentEngineMemoryRevisionsRequestParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ListAgentEngineMemoryRevisionsRequestParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ListAgentEngineMemoryRevisionsRequestParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ListAgentEngineMemoryRevisionsRequestParameters.builder()` + * for instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ListAgentEngineMemoryRevisionsRequestParameters.Builder(); + } + + /** + * Setter for name. + * + *

name: Name of the Agent Engine memory + */ + @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(ListAgentEngineMemoryRevisionsConfig config); + + /** + * Setter for config builder. + * + *

config: + */ + @CanIgnoreReturnValue + public Builder config(ListAgentEngineMemoryRevisionsConfig.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 ListAgentEngineMemoryRevisionsRequestParameters build(); + } + + /** Deserializes a JSON string to a ListAgentEngineMemoryRevisionsRequestParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static ListAgentEngineMemoryRevisionsRequestParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ListAgentEngineMemoryRevisionsRequestParameters.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsResponse.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsResponse.java new file mode 100644 index 0000000..0c5bc56 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/ListAgentEngineMemoryRevisionsResponse.java @@ -0,0 +1,157 @@ +/* + * 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 memory revisions. */ +@AutoValue +@JsonDeserialize(builder = ListAgentEngineMemoryRevisionsResponse.Builder.class) +public abstract class ListAgentEngineMemoryRevisionsResponse extends JsonSerializable { + /** Used to retain the full HTTP response. */ + @JsonProperty("sdkHttpResponse") + public abstract Optional sdkHttpResponse(); + + /** */ + @JsonProperty("nextPageToken") + public abstract Optional nextPageToken(); + + /** List of memory revisions. */ + @JsonProperty("memoryRevisions") + public abstract Optional> memoryRevisions(); + + /** Instantiates a builder for ListAgentEngineMemoryRevisionsResponse. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ListAgentEngineMemoryRevisionsResponse.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ListAgentEngineMemoryRevisionsResponse. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ListAgentEngineMemoryRevisionsResponse.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ListAgentEngineMemoryRevisionsResponse.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 memoryRevisions. + * + *

memoryRevisions: List of memory revisions. + */ + @JsonProperty("memoryRevisions") + public abstract Builder memoryRevisions(List memoryRevisions); + + /** + * Setter for memoryRevisions. + * + *

memoryRevisions: List of memory revisions. + */ + @CanIgnoreReturnValue + public Builder memoryRevisions(MemoryRevision... memoryRevisions) { + return memoryRevisions(Arrays.asList(memoryRevisions)); + } + + /** + * Setter for memoryRevisions builder. + * + *

memoryRevisions: List of memory revisions. + */ + @CanIgnoreReturnValue + public Builder memoryRevisions(MemoryRevision.Builder... memoryRevisionsBuilders) { + return memoryRevisions( + Arrays.asList(memoryRevisionsBuilders).stream() + .map(MemoryRevision.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder memoryRevisions(Optional> memoryRevisions); + + /** Clears the value of memoryRevisions field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMemoryRevisions() { + return memoryRevisions(Optional.empty()); + } + + public abstract ListAgentEngineMemoryRevisionsResponse build(); + } + + /** Deserializes a JSON string to a ListAgentEngineMemoryRevisionsResponse object. */ + @ExcludeFromGeneratedCoverageReport + public static ListAgentEngineMemoryRevisionsResponse fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ListAgentEngineMemoryRevisionsResponse.class); + } +} diff --git a/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/MemoryRevision.java b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/MemoryRevision.java new file mode 100644 index 0000000..7415660 --- /dev/null +++ b/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/genai/types/MemoryRevision.java @@ -0,0 +1,244 @@ +/* + * 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.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** A memory revision. */ +@AutoValue +@JsonDeserialize(builder = MemoryRevision.Builder.class) +public abstract class MemoryRevision extends JsonSerializable { + /** Output only. Timestamp when this Memory Revision was created. */ + @JsonProperty("createTime") + public abstract Optional createTime(); + + /** Output only. Timestamp of when this resource is considered expired. */ + @JsonProperty("expireTime") + public abstract Optional expireTime(); + + /** + * Output only. The extracted memories from the source content before consolidation when the + * memory was updated via GenerateMemories. This information was used to modify an existing Memory + * via Consolidation. + */ + @JsonProperty("extractedMemories") + public abstract Optional> extractedMemories(); + + /** + * Output only. The fact of the Memory Revision. This corresponds to the `fact` field of the + * parent Memory at the time of revision creation. + */ + @JsonProperty("fact") + public abstract Optional fact(); + + /** + * Output only. The labels of the Memory Revision. These labels are applied to the MemoryRevision + * when it is created based on `GenerateMemoriesRequest.revision_labels`. + */ + @JsonProperty("labels") + public abstract Optional> labels(); + + /** + * Identifier. The resource name of the Memory Revision. Format: + * `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/memories/{memory}/revisions/{memory_revision}` + */ + @JsonProperty("name") + public abstract Optional name(); + + /** Instantiates a builder for MemoryRevision. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_MemoryRevision.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for MemoryRevision. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `MemoryRevision.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_MemoryRevision.Builder(); + } + + /** + * Setter for createTime. + * + *

createTime: Output only. Timestamp when this Memory Revision 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 expireTime. + * + *

expireTime: Output only. Timestamp of when this resource is considered expired. + */ + @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 extractedMemories. + * + *

extractedMemories: Output only. The extracted memories from the source content before + * consolidation when the memory was updated via GenerateMemories. This information was used to + * modify an existing Memory via Consolidation. + */ + @JsonProperty("extractedMemories") + public abstract Builder extractedMemories(List extractedMemories); + + /** + * Setter for extractedMemories. + * + *

extractedMemories: Output only. The extracted memories from the source content before + * consolidation when the memory was updated via GenerateMemories. This information was used to + * modify an existing Memory via Consolidation. + */ + @CanIgnoreReturnValue + public Builder extractedMemories(IntermediateExtractedMemory... extractedMemories) { + return extractedMemories(Arrays.asList(extractedMemories)); + } + + /** + * Setter for extractedMemories builder. + * + *

extractedMemories: Output only. The extracted memories from the source content before + * consolidation when the memory was updated via GenerateMemories. This information was used to + * modify an existing Memory via Consolidation. + */ + @CanIgnoreReturnValue + public Builder extractedMemories( + IntermediateExtractedMemory.Builder... extractedMemoriesBuilders) { + return extractedMemories( + Arrays.asList(extractedMemoriesBuilders).stream() + .map(IntermediateExtractedMemory.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder extractedMemories( + Optional> extractedMemories); + + /** Clears the value of extractedMemories field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearExtractedMemories() { + return extractedMemories(Optional.empty()); + } + + /** + * Setter for fact. + * + *

fact: Output only. The fact of the Memory Revision. This corresponds to the `fact` field + * of the parent Memory at the time of revision creation. + */ + @JsonProperty("fact") + public abstract Builder fact(String fact); + + @ExcludeFromGeneratedCoverageReport + abstract Builder fact(Optional fact); + + /** Clears the value of fact field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearFact() { + return fact(Optional.empty()); + } + + /** + * Setter for labels. + * + *

labels: Output only. The labels of the Memory Revision. These labels are applied to the + * MemoryRevision when it is created based on `GenerateMemoriesRequest.revision_labels`. + */ + @JsonProperty("labels") + public abstract Builder labels(Map labels); + + @ExcludeFromGeneratedCoverageReport + abstract Builder labels(Optional> labels); + + /** Clears the value of labels field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearLabels() { + return labels(Optional.empty()); + } + + /** + * Setter for name. + * + *

name: Identifier. The resource name of the Memory Revision. Format: + * `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/memories/{memory}/revisions/{memory_revision}` + */ + @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()); + } + + public abstract MemoryRevision build(); + } + + /** Deserializes a JSON string to a MemoryRevision object. */ + @ExcludeFromGeneratedCoverageReport + public static MemoryRevision fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, MemoryRevision.class); + } +} diff --git a/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/genai/AgentEnginesMemoriesRevisionsTest.java b/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/genai/AgentEnginesMemoriesRevisionsTest.java new file mode 100644 index 0000000..85ee011 --- /dev/null +++ b/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/genai/AgentEnginesMemoriesRevisionsTest.java @@ -0,0 +1,64 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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.assertEquals; + +import com.google.cloud.vertexai.genai.types.ListAgentEngineMemoryRevisionsResponse; +import com.google.cloud.vertexai.genai.types.MemoryRevision; +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 AgentEnginesMemoriesRevisionsTest { + + @Test + public void testPrivateGetAgentEngineMemoryRevision() throws Exception { + Client client = + TestUtils.createClient( + true, "ae_memory_revisions_get/test_get_memory_revisions.vertex.json"); + + String name = + "projects/964831358985/locations/us-central1/reasoningEngines/2886612747586371584/memories/3858070028511346688/revisions/516064922187071488"; + + MemoryRevision revision = client.agentEngines.memories.revisions.get(name, null); + + assertEquals(revision.name().get(), name); + } + + @Test + public void testPrivateListAgentEngineMemoryRevisions() throws Exception { + Client client = + TestUtils.createClient( + true, + "ae_memory_revisions_private_list/test_private_list_memory_revisions.vertex.json"); + + String name = + "projects/964831358985/locations/us-central1/reasoningEngines/2886612747586371584/memories/3858070028511346688"; + + ListAgentEngineMemoryRevisionsResponse response = + client.agentEngines.memories.revisions.privateList(name, null); + + assertEquals( + response.memoryRevisions().get().get(0).name().get(), + name + "/revisions/516064922187071488"); + } +}