Reference documentation and code samples for the gapic-common class Gapic::GenericLRO::Operation.
A class used to wrap the longrunning operation objects, including the nonstandard ones
(nonstandard
meaning not conforming to the AIP-151).
It provides helper methods to poll and check for status of these operations.
Inherits
Methods
#done?
def done?() -> Boolean
Checks if the operation is done. This does not send a new api call, but checks the result of the previous api call to see if done.
- (Boolean) — Whether the operation is done.
#error
def error() -> Object, nil
If the operation response is an error, the error will be returned, otherwise returns nil.
- (Object, nil) — The error object.
#error?
def error?() -> Boolean
Checks if the operation is done and the result is an error. If the operation is not finished then this will return false.
- (Boolean) — Whether an error has been returned.
#initialize
def initialize(operation, client:, polling_method_name:, operation_status_field:, request_values: {}, operation_name_field: nil, operation_err_field: nil, operation_err_code_field: nil, operation_err_msg_field: nil, operation_copy_fields: {}, options: {}) -> Operation
- operation (Object) — The long-running operation object that is returned by the initial method call.
- client (Object) — The client that handles the polling for the longrunning operation.
- polling_method_name (String) — The name of the methods on the client that polls the longrunning operation.
-
operation_status_field (String) — The name of the
status
field in the underlying long-running operation object. Thestatus
field signals that the operation has finished. It should either contain symbols, and be set to:DONE
when finished or contain a boolean and be set totrue
when finished. -
request_values (Map<String, String>) (defaults to: {}) — The values that are to be copied from the request that
triggered the longrunning operation, into the request that polls for the longrunning operation.
The format is
name of the request field
->value
-
operation_name_field (String, nil) (defaults to: nil) — The name of the
name
field in the underlying long-running operation object. Optional. -
operation_err_field (String, nil) (defaults to: nil) — The name of the
error
field in the underlying long-running operation object. Theerror
field should be a message-type, and have same semantics asgoogle.rpc.Status
, including an integercode
subfield, that carries an error code. If theoperation_err_field
field is given, theoperation_err_code_field
andoperation_err_msg_field
parameters are ignored. Optional. -
operation_err_code_field (String, nil) (defaults to: nil) — The name of the
error_code
field in the underlying long-running operation object. It is ignored ifoperation_err_field
is given. Optional. -
operation_err_msg_field (String, nil) (defaults to: nil) — The name of the
error_message
field in the underlying long-running operation object. It is ignored ifoperation_err_field
is given. Optional. -
operation_copy_fields (Map<String, String>) (defaults to: {}) — The map of the fields that need to be copied from the
long-running operation object that the polling method returns to the polling request.
The format is
name of the operation object field
->name of the request field
(from
->to
) - options (Gapic::CallOptions) (defaults to: {}) — call options for this operation
- (Operation) — a new instance of Operation
#name
def name() -> String, nil
Returns the name of the operation, if specified.
- (String, nil) — The name of the operation.
#on_done
def on_done(&block) { |operation| ... }
Registers a callback to be run when a refreshed operation is marked as done. If the operation has completed prior to a call to this function the callback will be called instead of registered.
- operation (Gapic::Operation) — Yields the finished Operation.
#on_reload
def on_reload(&block) { |operation| ... }
Registers a callback to be run when an operation is being reloaded. If the operation has completed prior to a call to this function the callback will NOT be called or registered.
- operation (Gapic::Operation) — Yields the finished Operation.
#refresh!
def refresh!(options: nil) -> Gapic::GenericLRO::Operation
Reloads the operation object.
to customize the options object, using keys that match the arguments for CallOptions.new.
- options (Gapic::CallOptions, Hash) (defaults to: nil) — The options for making the RPC call. A Hash can be provided
- (Gapic::GenericLRO::Operation) — Since this method changes internal state, it returns itself.
#reload!
def reload!(options: nil) -> Gapic::GenericLRO::Operation
Reloads the operation object.
to customize the options object, using keys that match the arguments for CallOptions.new.
- options (Gapic::CallOptions, Hash) (defaults to: nil) — The options for making the RPC call. A Hash can be provided
- (Gapic::GenericLRO::Operation) — Since this method changes internal state, it returns itself.
#response
def response() -> Object, nil
If the operation is completed successfully, returns the underlying operation object, otherwise returns nil.
- (Object, nil) — The response of the operation.
#response?
def response?() -> Boolean
Checks if the operation is done and the result is not an error. If the operation is not finished then this will return false.
- (Boolean) — Whether a response has been returned.
#results
def results() -> Object, nil
If the operation is done, returns the response. If the operation response is an error, the error will be returned. Otherwise returns nil.
- (Object, nil) — The result of the operation or an error.
#wait_until_done!
def wait_until_done!(retry_policy: nil) { |operation| ... }
Blocking method to wait until the operation has completed or the maximum timeout has been reached. Upon completion, registered callbacks will be called, then - if a block is given - the block will be called.
- retry_policy (RetryPolicy, Hash, Proc) (defaults to: nil) — The policy for retry. A custom proc that takes the error as an argument and blocks can also be provided.
- operation (Gapic::GenericLRO::Operation) — Yields the finished Operation.