Google Cloud PHP shared dependency, providing functionality useful to all components. Client - Class LongRunningOperation (1.51.2)

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
NameDescription
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();
Returns
TypeDescription
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
NameDescription
options array

[optional] Configuration options.

Returns
TypeDescription
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;
}
Parameter
NameDescription
options array

[optional] Configuration options.

Returns
TypeDescription
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
NameDescription
options array

[optional] Configuration options.

Returns
TypeDescription
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
NameDescription
options array

[optional] Configuration options.

Returns
TypeDescription
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();
Parameter
NameDescription
options array

[optional] Configuration options.

Returns
TypeDescription
array[google.longrunning.Operation](https://cloud.google.com/spanner/docs/reference/rpc/google.longrunning#google.longrunning.Operation)

reload

Reload the Operation to check its status.

Example:

$result = $operation->reload();
Parameter
NameDescription
options array

[optional] Configuration Options.

Returns
TypeDescription
array[google.longrunning.Operation](https://cloud.google.com/spanner/docs/reference/rpc/google.longrunning#google.longrunning.Operation)

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();
Parameters
NameDescription
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.

Returns
TypeDescription
mixed|null

cancel

Cancel a Long Running Operation.

Example:

$operation->cancel();
Parameter
NameDescription
options array

Configuration options.

Returns
TypeDescription
void

delete

Delete a Long Running Operation.

Example:

$operation->delete();
Parameter
NameDescription
options array

Configuration Options.

Returns
TypeDescription
void

__debugInfo

Constants

WAIT_INTERVAL

Value: 1.0

STATE_IN_PROGRESS

Value: 'inProgress'

STATE_SUCCESS

Value: 'success'

STATE_ERROR

Value: 'error'