Class Operation<T,O extends Operation<T,O>>

java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.Operation<T,O>
Direct Known Subclasses:
GenerateVideosOperation, ImportFileOperation, UploadToFileSearchStoreOperation

public abstract class Operation<T,O extends Operation<T,O>> extends JsonSerializable
A long-running operation.
  • Constructor Details

    • Operation

      public Operation()
  • Method Details

    • name

      public abstract Optional<String> name()
      The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
    • metadata

      public abstract Optional<Map<String,Object>> metadata()
      Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
    • done

      public abstract Optional<Boolean> done()
      If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
    • error

      public abstract Optional<Map<String,Object>> error()
      The error result of the operation in case of failure or cancellation.
    • response

      public abstract Optional<T> response()
      The result of the operation.
    • fromApiResponse

      public abstract O fromApiResponse(com.fasterxml.jackson.databind.JsonNode apiResponse, boolean isVertexAi)
      Creates a new Operation object from an API response.
      Parameters:
      apiResponse - The API response.
      isVertexAi - Whether the API response is from Vertex AI.
      Returns:
      The new Operation object.