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.
Methods
__construct
connection
Google\Cloud\Core\LongRunning\LongRunningConnectionInterface
An implementation mapping to methods which handle LRO resolution in the service.
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();
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!";
}
options
array
[optional] Configuration options.
bool
state
Get the state of the Operation.
Return value will be one of LongRunningOperation::STATE_IN_PROGRESS
, LongRunningOperation::STATE_SUCCESS
or LongRunningOperation::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;
}
options
array
[optional] Configuration options.
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();
options
array
[optional] Configuration options.
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();
options
array
[optional] Configuration options.
array|null
info
Get the Operation info.
If the Operation state is not available, a service request may be executed by this method.
Example:
$info = $operation->info();
options
array
[optional] Configuration options.
array
reload
Reload the Operation to check its status.
Example:
$result = $operation->reload();
options
array
[optional] Configuration Options.
array
pollUntilComplete
Reload the operation until it is complete.
The return type of this method is dictated by the type of Operation. If $options.maxPollingDurationSeconds
is set, and the poll exceeds the
limit, the return will be null
.
Example:
$result = $operation->pollUntilComplete();
options
array
Configuration Options
↳ pollingIntervalSeconds
float
The polling interval to use, in seconds. Defaults to 1.0
.
↳ maxPollingDurationSeconds
float
The maximum amount of time to continue polling. Defaults to 0.0
.
mixed|null
cancel
Cancel a Long Running Operation.
Example:
$operation->cancel();
options
array
Configuration options.
void
delete
Delete a Long Running Operation.
Example:
$operation->delete();
options
array
Configuration Options.
void
__debugInfo
Constants
WAIT_INTERVAL
Value: 1.0
STATE_IN_PROGRESS
Value: 'inProgress'
STATE_SUCCESS
Value: 'success'
STATE_ERROR
Value: 'error'