OperationResponse
class OperationResponse
Response object from a long running API method.
The OperationResponse object is returned by API methods that perform a long running operation. It provides methods that can be used to poll the status of the operation, retrieve the results, and cancel the operation.
To support a long running operation, the server must implement the Operations API, which is used by the OperationResponse object. If more control is required, it is possible to make calls against the Operations API directly instead of via the OperationResponse object using an OperationsClient instance.
Constants
DEFAULT_POLLING_INTERVAL |
|
Methods
OperationResponse constructor.
Check whether the operation has completed.
Check whether the operation completed successfully. If the operation is not complete, or if the operation failed, return false.
Check whether the operation failed. If the operation is not complete, or if the operation succeeded, return false.
Get the formatted name of the operation
Poll the server in a loop until the operation is complete.
Reload the status of the operation with a request to the service.
Return the result of the operation. If operationSucceeded() is false, return null.
If the operation failed, return the status. If operationFailed() is false, return null.
Get an array containing the values of 'operationReturnType' and 'metadataReturnType' (which may be null). The array can be passed as the $options argument to the constructor when creating another OperationResponse object.
No description
No description
Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it will throw an ApiException with code \google\rpc\Code::UNIMPLEMENTED. Clients can continue to use reload and pollUntilComplete methods to check whether the cancellation succeeded or whether the operation completed despite cancellation.
Delete the long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation.
Get the metadata returned with the last proto response. If a metadata type was provided, then the return value will be of that type - otherwise, the return value will be of type Any. If no metadata object is available, returns null.
Details
at line 73
__construct(string $operationName, OperationsClient $operationsClient, array $options = [])
OperationResponse constructor.
at line 93
bool
isDone()
Check whether the operation has completed.
at line 106
bool
operationSucceeded()
Check whether the operation completed successfully. If the operation is not complete, or if the operation failed, return false.
at line 117
bool
operationFailed()
Check whether the operation failed. If the operation is not complete, or if the operation succeeded, return false.
at line 127
string
getName()
Get the formatted name of the operation
at line 151
bool
pollUntilComplete(array $options = [])
Poll the server in a loop until the operation is complete.
Return true if the operation completed, otherwise return false. If the $options['maxPollingDuration'] setting is not set (or set <= 0.0) then pollUntilComplete will continue polling until the operation completes, and therefore will always return true.
at line 178
reload()
Reload the status of the operation with a request to the service.
at line 192
mixed|null
getResult()
Return the result of the operation. If operationSucceeded() is false, return null.
at line 214
Status|null
getError()
If the operation failed, return the status. If operationFailed() is false, return null.
at line 229
array
getReturnTypeOptions()
Get an array containing the values of 'operationReturnType' and 'metadataReturnType' (which may be null). The array can be passed as the $options argument to the constructor when creating another OperationResponse object.
at line 240
Operation|null
getLastProtoResponse()
at line 249
OperationsClient
getOperationsClient()
at line 267
cancel()
Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it will throw an ApiException with code \google\rpc\Code::UNIMPLEMENTED. Clients can continue to use reload and pollUntilComplete methods to check whether the cancellation succeeded or whether the operation completed despite cancellation.
On successful cancellation, the operation is not deleted; instead, it becomes an operation with a getError() value with a \google\rpc\Status code of 1, corresponding to \google\rpc\Code::CANCELLED.
at line 280
delete()
Delete the long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation.
If the server doesn't support this method, it will throw an ApiException with code google\rpc\Code::UNIMPLEMENTED.
at line 293
mixed
getMetadata()
Get the metadata returned with the last proto response. If a metadata type was provided, then the return value will be of that type - otherwise, the return value will be of type Any. If no metadata object is available, returns null.