Class Operation
-
- All Implemented Interfaces:
public abstract class Operation<T, O extends Operation<T, O>> extends JsonSerializable
A long-running operation.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description Operation()
-
Method Summary
Modifier and Type Method Description abstract Optional<String>name()The server-assigned name, which is only unique within the same service that originally returns it. abstract Optional<Map<String, Object>>metadata()Service-specific metadata associated with the operation. abstract Optional<Boolean>done()If the value is `false`, it means the operation is still in progress. abstract Optional<Map<String, Object>>error()The error result of the operation in case of failure or cancellation. abstract Optional<T>response()The result of the operation. abstract OfromApiResponse(JsonNode apiResponse, boolean isVertexAi)Creates a new Operation object from an API response. -
Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
name
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
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
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
abstract Optional<Map<String, Object>> error()
The error result of the operation in case of failure or cancellation.
-
fromApiResponse
abstract O fromApiResponse(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.
-
-
-
-