Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class LongRunningOperation.
Represent and interact with a Long Running Operation.
Namespace
Google \ Cloud \ Core \ LongRunning
Methods
__construct
Parameters
Name
Description
connection
LongRunningConnectionInterface
An implementation
mapping to methods which handle LRO resolution in the service.
This object is created by internal classes,
and should not be instantiated outside of this context.
name
string
The Operation name.
callablesMap
array
An collection of form [(string) typeUrl, (callable) callable]
providing a function to invoke when an operation completes. The
callable Type should correspond to an expected value of
operation.metadata.typeUrl.
info
array
[optional] The operation info.
name
Return the Operation name.
Example:
$name = $operation->name();
Returns
Type
Description
string
done
Check if the Operation is done.
If the Operation state is not available, a service request may be executed
by this method.
Example:
if ($operation->done()) {
echo "The operation is done!";
}
Parameter
Name
Description
options
array
[optional] Configuration options.
Returns
Type
Description
bool
state
Get the state of the Operation.
Return value will be one ofLongRunningOperation::STATE_IN_PROGRESS,LongRunningOperation::STATE_SUCCESSorLongRunningOperation::STATE_ERROR.
If the Operation state is not available, a service request may be executed
by this method.
Example:
switch ($operation->state()) {
case LongRunningOperation::STATE_IN_PROGRESS:
echo "Operation is in progress";
break;
case LongRunningOperation::STATE_SUCCESS:
echo "Operation succeeded";
break;
case LongRunningOperation::STATE_ERROR:
echo "Operation failed";
break;
}
Parameter
Name
Description
options
array
[optional] Configuration options.
Returns
Type
Description
string
result
Get the Operation result.
The return type of this method is dictated by the type of Operation.
Returns null if the Operation is not yet complete, or if an error occurred.
If the Operation state is not available, a service request may be executed
by this method.
Example:
$result = $operation->result();
Parameter
Name
Description
options
array
[optional] Configuration options.
Returns
Type
Description
mixed|null
error
Get the Operation error.
Returns null if the Operation is not yet complete, or if no error occurred.
If the Operation state is not available, a service request may be executed
by this method.
Example:
$error = $operation->error();
Parameter
Name
Description
options
array
[optional] Configuration options.
Returns
Type
Description
array|null
info
Get the Operation info.
If the Operation state is not available, a service request may be executed
by this method.
The return type of this method is dictated by the type of Operation. If$options.maxPollingDurationSecondsis set, and the poll exceeds the
limit, the return will benull.
Example:
$result = $operation->pollUntilComplete();
Parameters
Name
Description
options
array
Configuration Options
↳ pollingIntervalSeconds
float
The polling interval to use, in seconds.Defaults to1.0.
↳ maxPollingDurationSeconds
float
The maximum amount of time to continue polling.Defaults to0.0.
[[["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-09-04 UTC."],[],[],null,["# Google Cloud PHP shared dependency, providing functionality useful to all components. Client - Class LongRunningOperation (1.64.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.64.2 (latest)](/php/docs/reference/cloud-core/latest/LongRunning.LongRunningOperation)\n- [1.64.1](/php/docs/reference/cloud-core/1.64.1/LongRunning.LongRunningOperation)\n- [1.63.0](/php/docs/reference/cloud-core/1.63.0/LongRunning.LongRunningOperation)\n- [1.62.3](/php/docs/reference/cloud-core/1.62.3/LongRunning.LongRunningOperation)\n- [1.61.0](/php/docs/reference/cloud-core/1.61.0/LongRunning.LongRunningOperation)\n- [1.60.1](/php/docs/reference/cloud-core/1.60.1/LongRunning.LongRunningOperation)\n- [1.59.1](/php/docs/reference/cloud-core/1.59.1/LongRunning.LongRunningOperation)\n- [1.58.2](/php/docs/reference/cloud-core/1.58.2/LongRunning.LongRunningOperation)\n- [1.53.0](/php/docs/reference/cloud-core/1.53.0/LongRunning.LongRunningOperation)\n- [1.52.11](/php/docs/reference/cloud-core/1.52.11/LongRunning.LongRunningOperation)\n- [1.51.2](/php/docs/reference/cloud-core/1.51.2/LongRunning.LongRunningOperation)\n- [1.50.0](/php/docs/reference/cloud-core/1.50.0/LongRunning.LongRunningOperation)\n- [1.49.3](/php/docs/reference/cloud-core/1.49.3/LongRunning.LongRunningOperation)\n- [1.48.1](/php/docs/reference/cloud-core/1.48.1/LongRunning.LongRunningOperation) \nReference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class LongRunningOperation.\n\nRepresent and interact with a Long Running Operation.\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Core \\\\ LongRunning\n\nMethods\n-------\n\n### __construct\n\n### name\n\nReturn the Operation name.\n\nExample: \n\n $name = $operation-\u003ename();\n\n### done\n\nCheck if the Operation is done.\n\nIf the Operation state is not available, a service request may be executed\nby this method.\n\nExample: \n\n if ($operation-\u003edone()) {\n echo \"The operation is done!\";\n }\n\n### state\n\nGet the state of the Operation.\n\nReturn value will be one of `LongRunningOperation::STATE_IN_PROGRESS`,\n`LongRunningOperation::STATE_SUCCESS` or\n`LongRunningOperation::STATE_ERROR`.\n\nIf the Operation state is not available, a service request may be executed\nby this method.\n\nExample: \n\n switch ($operation-\u003estate()) {\n case LongRunningOperation::STATE_IN_PROGRESS:\n echo \"Operation is in progress\";\n break;\n\n case LongRunningOperation::STATE_SUCCESS:\n echo \"Operation succeeded\";\n break;\n\n case LongRunningOperation::STATE_ERROR:\n echo \"Operation failed\";\n break;\n }\n\n### result\n\nGet the Operation result.\n\nThe return type of this method is dictated by the type of Operation.\n\nReturns null if the Operation is not yet complete, or if an error occurred.\n\nIf the Operation state is not available, a service request may be executed\nby this method.\n\nExample: \n\n $result = $operation-\u003eresult();\n\n### error\n\nGet the Operation error.\n\nReturns null if the Operation is not yet complete, or if no error occurred.\n\nIf the Operation state is not available, a service request may be executed\nby this method.\n\nExample: \n\n $error = $operation-\u003eerror();\n\n### info\n\nGet the Operation info.\n\nIf the Operation state is not available, a service request may be executed\nby this method.\n\nExample: \n\n $info = $operation-\u003einfo();\n\n### reload\n\nReload the Operation to check its status.\n\nExample: \n\n $result = $operation-\u003ereload();\n\n### pollUntilComplete\n\nReload the operation until it is complete.\n\nThe return type of this method is dictated by the type of Operation. If\n`$options.maxPollingDurationSeconds` is set, and the poll exceeds the\nlimit, the return will be `null`.\n\nExample: \n\n $result = $operation-\u003epollUntilComplete();\n\n### cancel\n\nCancel a Long Running Operation.\n\nExample: \n\n $operation-\u003ecancel();\n\n### delete\n\nDelete a Long Running Operation.\n\nExample: \n\n $operation-\u003edelete();\n\n### __debugInfo\n\nConstants\n---------\n\n### WAIT_INTERVAL\n\n Value: 1.0\n\n### STATE_IN_PROGRESS\n\n Value: 'inProgress'\n\n### STATE_SUCCESS\n\n Value: 'success'\n\n### STATE_ERROR\n\n Value: 'error'"]]