Class GcsArtifactService

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

public final class GcsArtifactService extends Object implements BaseArtifactService
An artifact service implementation using Google Cloud Storage (GCS).
  • Constructor Details

    • GcsArtifactService

      public GcsArtifactService(String bucketName, com.google.cloud.storage.Storage storageClient)
      Initializes the GcsArtifactService.
      Parameters:
      bucketName - The name of the GCS bucket to use.
      storageClient - The GCS storage client instance.
  • 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 to GCS and assigns a new version.
      Specified by:
      saveArtifact in interface BaseArtifactService
      Parameters:
      appName - Application name.
      userId - User ID.
      sessionId - Session ID.
      filename - Artifact filename.
      artifact - Artifact content to save.
      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 from GCS.
      Specified by:
      loadArtifact in interface BaseArtifactService
      Parameters:
      appName - Application name.
      userId - User ID.
      sessionId - Session ID.
      filename - Artifact filename.
      version - Optional version to load. Loads latest if empty.
      Returns:
      Maybe with loaded artifact, or empty if not found.
    • listArtifactKeys

      public io.reactivex.rxjava3.core.Single<ListArtifactsResponse> listArtifactKeys(String appName, String userId, String sessionId)
      Lists artifact filenames for a user and session.
      Specified by:
      listArtifactKeys in interface BaseArtifactService
      Parameters:
      appName - Application name.
      userId - User ID.
      sessionId - Session ID.
      Returns:
      Single with sorted 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 specified artifact from GCS.
      Specified by:
      deleteArtifact in interface BaseArtifactService
      Parameters:
      appName - Application name.
      userId - User ID.
      sessionId - Session ID.
      filename - Artifact filename.
      Returns:
      Completable indicating operation 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 available versions for a given artifact.
      Specified by:
      listVersions in interface BaseArtifactService
      Parameters:
      appName - Application name.
      userId - User ID.
      sessionId - Session ID.
      filename - Artifact filename.
      Returns:
      Single with sorted list of version numbers.