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.
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. The status 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 to true 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. The error field should be a message-type, and have same semantics as google.rpc.Status, including
an integer code subfield, that carries an error code. If the operation_err_field field is given,
the operation_err_code_field and operation_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 if operation_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 if operation_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
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.
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.
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.
Parameter
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# gapic-common - Class Gapic::GenericLRO::Operation (v1.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.1.0 (latest)](/ruby/docs/reference/gapic-common/latest/Gapic-GenericLRO-Operation)\n- [1.0.1](/ruby/docs/reference/gapic-common/1.0.1/Gapic-GenericLRO-Operation)\n- [0.26.0](/ruby/docs/reference/gapic-common/0.26.0/Gapic-GenericLRO-Operation)\n- [0.25.0](/ruby/docs/reference/gapic-common/0.25.0/Gapic-GenericLRO-Operation)\n- [0.24.0](/ruby/docs/reference/gapic-common/0.24.0/Gapic-GenericLRO-Operation) \nReference documentation and code samples for the gapic-common class Gapic::GenericLRO::Operation.\n\nA class used to wrap the longrunning operation objects, including the nonstandard ones\n(`nonstandard` meaning not conforming to the AIP-151).\nIt provides helper methods to poll and check for status of these operations. \n\nInherits\n--------\n\n- [Gapic::GenericLRO::BaseOperation](./Gapic-GenericLRO-BaseOperation)\n\nMethods\n-------\n\n### #done?\n\n def done?() -\u003e Boolean\n\nChecks if the operation is done. This does not send a new api call, but checks the result of the previous api\ncall to see if done. \n**Returns**\n\n- (Boolean) --- Whether the operation is done.\n\n### #error\n\n def error() -\u003e Object, nil\n\nIf the operation response is an error, the error will be returned, otherwise returns nil. \n**Returns**\n\n- (Object, nil) --- The error object.\n\n### #error?\n\n def error?() -\u003e Boolean\n\nChecks if the operation is done and the result is an error. If the operation is not finished then this will\nreturn false. \n**Returns**\n\n- (Boolean) --- Whether an error has been returned.\n\n### #initialize\n\n 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: {}) -\u003e Operation\n\n**Parameters**\n\n- **operation** (Object) --- The long-running operation object that is returned by the initial method call.\n- **client** (Object) --- The client that handles the polling for the longrunning operation.\n- **polling_method_name** (String) --- The name of the methods on the client that polls the longrunning operation.\n- **operation_status_field** (String) --- The name of the `status` field in the underlying long-running operation object. The `status` 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 to `true` when finished.\n- **request_values** (Map\\\u003cString, String\\\u003e) *(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` -\\\u003e `value`\n- **operation_name_field** (String, nil) *(defaults to: nil)* --- The name of the `name` field in the underlying long-running operation object. Optional.\n- **operation_err_field** (String, nil) *(defaults to: nil)* --- The name of the `error` field in the underlying long-running operation object. The `error` field should be a message-type, and have same semantics as `google.rpc.Status`, including an integer `code` subfield, that carries an error code. If the `operation_err_field` field is given, the `operation_err_code_field` and `operation_err_msg_field` parameters are ignored. Optional.\n- **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 if `operation_err_field` is given. Optional.\n- **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 if `operation_err_field` is given. Optional.\n- **operation_copy_fields** (Map\\\u003cString, String\\\u003e) *(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` -\\\u003e `name of the request field` (`from` -\\\u003e `to`)\n- **options** ([Gapic::CallOptions](./Gapic-CallOptions)) *(defaults to: {})* --- call options for this operation \n**Returns**\n\n- ([Operation](./Gapic-GenericLRO-Operation)) --- a new instance of Operation\n\n### #name\n\n def name() -\u003e String, nil\n\nReturns the name of the operation, if specified. \n**Returns**\n\n- (String, nil) --- The name of the operation.\n\n### #on_done\n\n def on_done(&block) { |operation| ... }\n\nRegisters a callback to be run when a refreshed operation is marked as done. If the operation has completed\nprior to a call to this function the callback will be called instead of registered. \n**Yield Parameter**\n\n- **operation** ([Gapic::Operation](./Gapic-Operation)) --- Yields the finished Operation.\n\n### #on_reload\n\n def on_reload(&block) { |operation| ... }\n\nRegisters a callback to be run when an operation is being reloaded. If the operation has completed\nprior to a call to this function the callback will NOT be called or registered. \n**Yield Parameter**\n\n- **operation** ([Gapic::Operation](./Gapic-Operation)) --- Yields the finished Operation.\n\n### #refresh!\n\n def refresh!(options: nil) -\u003e Gapic::GenericLRO::Operation\n\n**Alias Of** : [#reload!](./Gapic-GenericLRO-Operation#Gapic__GenericLRO__Operation_reload!_instance_) \nReloads the operation object.\n\n\n\u003cbr /\u003e\n\nto customize the options object, using keys that match the arguments for CallOptions.new. \n**Parameter**\n\n- **options** ([Gapic::CallOptions](./Gapic-CallOptions), Hash) *(defaults to: nil)* --- The options for making the RPC call. A Hash can be provided \n**Returns**\n\n- ([Gapic::GenericLRO::Operation](./Gapic-GenericLRO-Operation)) --- Since this method changes internal state, it returns itself.\n\n### #reload!\n\n def reload!(options: nil) -\u003e Gapic::GenericLRO::Operation\n\n**Aliases**\n\n- [#refresh!](./Gapic-GenericLRO-Operation#Gapic__GenericLRO__Operation_refresh!_instance_) \nReloads the operation object.\n\n\n\u003cbr /\u003e\n\nto customize the options object, using keys that match the arguments for CallOptions.new. \n**Parameter**\n\n- **options** ([Gapic::CallOptions](./Gapic-CallOptions), Hash) *(defaults to: nil)* --- The options for making the RPC call. A Hash can be provided \n**Returns**\n\n- ([Gapic::GenericLRO::Operation](./Gapic-GenericLRO-Operation)) --- Since this method changes internal state, it returns itself.\n\n### #response\n\n def response() -\u003e Object, nil\n\nIf the operation is completed successfully, returns the underlying operation object, otherwise returns nil. \n**Returns**\n\n- (Object, nil) --- The response of the operation.\n\n### #response?\n\n def response?() -\u003e Boolean\n\nChecks if the operation is done and the result is not an error. If the operation is not finished then this will\nreturn false. \n**Returns**\n\n- (Boolean) --- Whether a response has been returned.\n\n### #results\n\n def results() -\u003e Object, nil\n\nIf the operation is done, returns the response. If the operation response is an error, the error will be\nreturned. Otherwise returns nil. \n**Returns**\n\n- (Object, nil) --- The result of the operation or an error.\n\n### #wait_until_done!\n\n def wait_until_done!(retry_policy: nil) { |operation| ... }\n\nBlocking method to wait until the operation has completed or the maximum timeout has been reached. Upon\ncompletion, registered callbacks will be called, then - if a block is given - the block will be called. \n**Parameter**\n\n- **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. \n**Yield Parameter**\n\n- **operation** ([Gapic::GenericLRO::Operation](./Gapic-GenericLRO-Operation)) --- Yields the finished Operation."]]