Class GcsArtifactService
java.lang.Object
com.google.adk.artifacts.GcsArtifactService
- All Implemented Interfaces:
BaseArtifactService
An artifact service implementation using Google Cloud Storage (GCS).
-
Constructor Summary
ConstructorsConstructorDescriptionGcsArtifactService
(String bucketName, com.google.cloud.storage.Storage storageClient) Initializes the GcsArtifactService. -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Completable
deleteArtifact
(String appName, String userId, String sessionId, String filename) Deletes all versions of the specified artifact from GCS.io.reactivex.rxjava3.core.Single
<ListArtifactsResponse> listArtifactKeys
(String appName, String userId, String sessionId) Lists artifact filenames for a user and session.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.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.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.
-
Constructor Details
-
GcsArtifactService
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 interfaceBaseArtifactService
- 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 interfaceBaseArtifactService
- 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 interfaceBaseArtifactService
- 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 interfaceBaseArtifactService
- 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 interfaceBaseArtifactService
- Parameters:
appName
- Application name.userId
- User ID.sessionId
- Session ID.filename
- Artifact filename.- Returns:
- Single with sorted list of version numbers.
-