Class InMemoryArtifactService

java.lang.Object
com.google.adk.artifacts.InMemoryArtifactService
All Implemented Interfaces:
BaseArtifactService

public final class InMemoryArtifactService extends Object implements BaseArtifactService
An in-memory implementation of the BaseArtifactService.
  • Constructor Details

    • InMemoryArtifactService

      public InMemoryArtifactService()
  • Method Details

    • saveArtifact

      public io.reactivex.rxjava3.core.Single<Integer> saveArtifact(String appName, String userId, String sessionId, String filename, com.google.genai.types.Part artifact)
      Saves an artifact in memory and assigns a new version.
      Specified by:
      saveArtifact in interface BaseArtifactService
      Parameters:
      appName - the app name
      userId - the user ID
      sessionId - the session ID
      filename - the filename
      artifact - the artifact
      Returns:
      Single with assigned version number.
    • loadArtifact

      public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String appName, String userId, String sessionId, String filename, Optional<Integer> version)
      Loads an artifact by version or latest.
      Specified by:
      loadArtifact in interface BaseArtifactService
      Parameters:
      appName - the app name
      userId - the user ID
      sessionId - the session ID
      filename - the filename
      version - Optional version number. If null, loads the latest version.
      Returns:
      Maybe with the artifact, or empty if not found.
    • listArtifactKeys

      public io.reactivex.rxjava3.core.Single<ListArtifactsResponse> listArtifactKeys(String appName, String userId, String sessionId)
      Lists filenames of stored artifacts for the session.
      Specified by:
      listArtifactKeys in interface BaseArtifactService
      Parameters:
      appName - the app name
      userId - the user ID
      sessionId - the session ID
      Returns:
      Single with list of artifact filenames.
    • deleteArtifact

      public io.reactivex.rxjava3.core.Completable deleteArtifact(String appName, String userId, String sessionId, String filename)
      Deletes all versions of the given artifact.
      Specified by:
      deleteArtifact in interface BaseArtifactService
      Parameters:
      appName - the app name
      userId - the user ID
      sessionId - the session ID
      filename - the filename
      Returns:
      Completable indicating completion.
    • listVersions

      public io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<Integer>> listVersions(String appName, String userId, String sessionId, String filename)
      Lists all versions of the specified artifact.
      Specified by:
      listVersions in interface BaseArtifactService
      Parameters:
      appName - the app name
      userId - the user ID
      sessionId - the session ID
      filename - the artifact filename
      Returns:
      Single with list of version numbers.