├── VERSION ├── metadata ├── Longrunning │ └── Operations.php └── README.md ├── .gitattributes ├── SECURITY.md ├── src ├── ApiCore │ └── LongRunning │ │ ├── OperationsClient.php │ │ └── Gapic │ │ └── OperationsGapicClient.php └── LongRunning │ ├── OperationsClient.php │ ├── GetOperationRequest.php │ ├── DeleteOperationRequest.php │ ├── CancelOperationRequest.php │ ├── resources │ ├── operations_client_config.json │ ├── operations_rest_client_config.php │ └── operations_descriptor_config.php │ ├── WaitOperationRequest.php │ ├── ListOperationsResponse.php │ ├── OperationInfo.php │ ├── OperationsGrpcClient.php │ ├── ListOperationsRequest.php │ ├── Operation.php │ ├── Client │ └── OperationsClient.php │ └── Gapic │ └── OperationsGapicClient.php ├── CONTRIBUTING.md ├── composer.json ├── CODE_OF_CONDUCT.md ├── README.md └── LICENSE /VERSION: -------------------------------------------------------------------------------- 1 | 0.6.0 2 | -------------------------------------------------------------------------------- /metadata/Longrunning/Operations.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/php-longrunning/HEAD/metadata/Longrunning/Operations.php -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | /*.xml.dist export-ignore 2 | /tests export-ignore 3 | /.github export-ignore 4 | /.OwlBot.yaml export-ignore 5 | /owlbot.py export-ignore 6 | /src/**/gapic_metadata.json export-ignore 7 | -------------------------------------------------------------------------------- /metadata/README.md: -------------------------------------------------------------------------------- 1 | # Google Protobuf Metadata Classes 2 | 3 | ## WARNING! 4 | 5 | These classes are not intended for direct use - they exist only to support 6 | the generated protobuf classes in src/ 7 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). 4 | 5 | The Google Security Team will respond within 5 working days of your report on g.co/vulnz. 6 | 7 | We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. 8 | -------------------------------------------------------------------------------- /src/ApiCore/LongRunning/OperationsClient.php: -------------------------------------------------------------------------------- 1 | Idiomatic PHP client for [Google LongRunning API](https://cloud.google.com/service-infrastructure/docs/service-management/reference/rpc/google.longrunning). 4 | 5 | [![Latest Stable Version](https://poser.pugx.org/google/longrunning/v/stable)](https://packagist.org/packages/google/longrunning) [![Packagist](https://img.shields.io/packagist/dm/google/longrunning.svg)](https://packagist.org/packages/google/longrunning) 6 | 7 | * [API documentation](https://cloud.google.com/service-infrastructure/docs/service-management/reference/rpc/google.longrunning) 8 | 9 | **NOTE:** This repository is part of [Google Cloud PHP](https://github.com/googleapis/google-cloud-php). Any 10 | support requests, bug reports, or development contributions should be directed to 11 | that project. 12 | 13 | ### Installation 14 | 15 | To begin, install the preferred dependency manager for PHP, [Composer](https://getcomposer.org/). 16 | 17 | Now to install just this component: 18 | 19 | ```sh 20 | $ composer require google/longrunning 21 | ``` 22 | 23 | This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits offered by gRPC (such as streaming methods) 24 | please see our [gRPC installation guide](https://cloud.google.com/php/grpc). 25 | 26 | ### Authentication 27 | 28 | Please see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md) for more information 29 | on authenticating your client. Once authenticated, you'll be ready to start making requests. 30 | 31 | ### Debugging 32 | 33 | Please see our [Debugging guide](https://github.com/googleapis/google-cloud-php/blob/main/DEBUG.md) 34 | for more information about the debugging tools. 35 | 36 | ### Version 37 | 38 | This component is considered beta. As such, it should be expected to be mostly 39 | stable and we're working towards a release candidate. We will address issues 40 | and requests with a higher priority. 41 | 42 | ### Next Steps 43 | 44 | 1. Understand the [official documentation](https://cloud.google.com/service-infrastructure/docs/service-management/reference/rpc/google.longrunning/docs). 45 | -------------------------------------------------------------------------------- /src/LongRunning/GetOperationRequest.php: -------------------------------------------------------------------------------- 1 | google.longrunning.GetOperationRequest 16 | */ 17 | class GetOperationRequest extends \Google\Protobuf\Internal\Message 18 | { 19 | /** 20 | * The name of the operation resource. 21 | * 22 | * Generated from protobuf field string name = 1; 23 | */ 24 | private $name = ''; 25 | 26 | /** 27 | * @param string $name The name of the operation resource. 28 | * 29 | * @return \Google\LongRunning\GetOperationRequest 30 | * 31 | * @experimental 32 | */ 33 | public static function build(string $name): self 34 | { 35 | return (new self()) 36 | ->setName($name); 37 | } 38 | 39 | /** 40 | * Constructor. 41 | * 42 | * @param array $data { 43 | * Optional. Data for populating the Message object. 44 | * 45 | * @type string $name 46 | * The name of the operation resource. 47 | * } 48 | */ 49 | public function __construct($data = NULL) { 50 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 51 | parent::__construct($data); 52 | } 53 | 54 | /** 55 | * The name of the operation resource. 56 | * 57 | * Generated from protobuf field string name = 1; 58 | * @return string 59 | */ 60 | public function getName() 61 | { 62 | return $this->name; 63 | } 64 | 65 | /** 66 | * The name of the operation resource. 67 | * 68 | * Generated from protobuf field string name = 1; 69 | * @param string $var 70 | * @return $this 71 | */ 72 | public function setName($var) 73 | { 74 | GPBUtil::checkString($var, True); 75 | $this->name = $var; 76 | 77 | return $this; 78 | } 79 | 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/LongRunning/DeleteOperationRequest.php: -------------------------------------------------------------------------------- 1 | google.longrunning.DeleteOperationRequest 16 | */ 17 | class DeleteOperationRequest extends \Google\Protobuf\Internal\Message 18 | { 19 | /** 20 | * The name of the operation resource to be deleted. 21 | * 22 | * Generated from protobuf field string name = 1; 23 | */ 24 | private $name = ''; 25 | 26 | /** 27 | * @param string $name The name of the operation resource to be deleted. 28 | * 29 | * @return \Google\LongRunning\DeleteOperationRequest 30 | * 31 | * @experimental 32 | */ 33 | public static function build(string $name): self 34 | { 35 | return (new self()) 36 | ->setName($name); 37 | } 38 | 39 | /** 40 | * Constructor. 41 | * 42 | * @param array $data { 43 | * Optional. Data for populating the Message object. 44 | * 45 | * @type string $name 46 | * The name of the operation resource to be deleted. 47 | * } 48 | */ 49 | public function __construct($data = NULL) { 50 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 51 | parent::__construct($data); 52 | } 53 | 54 | /** 55 | * The name of the operation resource to be deleted. 56 | * 57 | * Generated from protobuf field string name = 1; 58 | * @return string 59 | */ 60 | public function getName() 61 | { 62 | return $this->name; 63 | } 64 | 65 | /** 66 | * The name of the operation resource to be deleted. 67 | * 68 | * Generated from protobuf field string name = 1; 69 | * @param string $var 70 | * @return $this 71 | */ 72 | public function setName($var) 73 | { 74 | GPBUtil::checkString($var, True); 75 | $this->name = $var; 76 | 77 | return $this; 78 | } 79 | 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/LongRunning/CancelOperationRequest.php: -------------------------------------------------------------------------------- 1 | google.longrunning.CancelOperationRequest 16 | */ 17 | class CancelOperationRequest extends \Google\Protobuf\Internal\Message 18 | { 19 | /** 20 | * The name of the operation resource to be cancelled. 21 | * 22 | * Generated from protobuf field string name = 1; 23 | */ 24 | private $name = ''; 25 | 26 | /** 27 | * @param string $name The name of the operation resource to be cancelled. 28 | * 29 | * @return \Google\LongRunning\CancelOperationRequest 30 | * 31 | * @experimental 32 | */ 33 | public static function build(string $name): self 34 | { 35 | return (new self()) 36 | ->setName($name); 37 | } 38 | 39 | /** 40 | * Constructor. 41 | * 42 | * @param array $data { 43 | * Optional. Data for populating the Message object. 44 | * 45 | * @type string $name 46 | * The name of the operation resource to be cancelled. 47 | * } 48 | */ 49 | public function __construct($data = NULL) { 50 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 51 | parent::__construct($data); 52 | } 53 | 54 | /** 55 | * The name of the operation resource to be cancelled. 56 | * 57 | * Generated from protobuf field string name = 1; 58 | * @return string 59 | */ 60 | public function getName() 61 | { 62 | return $this->name; 63 | } 64 | 65 | /** 66 | * The name of the operation resource to be cancelled. 67 | * 68 | * Generated from protobuf field string name = 1; 69 | * @param string $var 70 | * @return $this 71 | */ 72 | public function setName($var) 73 | { 74 | GPBUtil::checkString($var, True); 75 | $this->name = $var; 76 | 77 | return $this; 78 | } 79 | 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/LongRunning/resources/operations_client_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "interfaces": { 3 | "google.longrunning.Operations": { 4 | "retry_codes": { 5 | "no_retry_codes": [], 6 | "retry_policy_1_codes": [ 7 | "UNAVAILABLE" 8 | ] 9 | }, 10 | "retry_params": { 11 | "no_retry_params": { 12 | "initial_retry_delay_millis": 0, 13 | "retry_delay_multiplier": 0.0, 14 | "max_retry_delay_millis": 0, 15 | "initial_rpc_timeout_millis": 0, 16 | "rpc_timeout_multiplier": 1.0, 17 | "max_rpc_timeout_millis": 0, 18 | "total_timeout_millis": 0 19 | }, 20 | "retry_policy_1_params": { 21 | "initial_retry_delay_millis": 500, 22 | "retry_delay_multiplier": 2.0, 23 | "max_retry_delay_millis": 10000, 24 | "initial_rpc_timeout_millis": 10000, 25 | "rpc_timeout_multiplier": 1.0, 26 | "max_rpc_timeout_millis": 10000, 27 | "total_timeout_millis": 10000 28 | } 29 | }, 30 | "methods": { 31 | "CancelOperation": { 32 | "timeout_millis": 10000, 33 | "retry_codes_name": "retry_policy_1_codes", 34 | "retry_params_name": "retry_policy_1_params" 35 | }, 36 | "DeleteOperation": { 37 | "timeout_millis": 10000, 38 | "retry_codes_name": "retry_policy_1_codes", 39 | "retry_params_name": "retry_policy_1_params" 40 | }, 41 | "GetOperation": { 42 | "timeout_millis": 10000, 43 | "retry_codes_name": "retry_policy_1_codes", 44 | "retry_params_name": "retry_policy_1_params" 45 | }, 46 | "ListOperations": { 47 | "timeout_millis": 10000, 48 | "retry_codes_name": "retry_policy_1_codes", 49 | "retry_params_name": "retry_policy_1_params" 50 | }, 51 | "WaitOperation": { 52 | "timeout_millis": 60000, 53 | "retry_codes_name": "no_retry_codes", 54 | "retry_params_name": "no_retry_params" 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/LongRunning/resources/operations_rest_client_config.php: -------------------------------------------------------------------------------- 1 | [ 25 | 'google.longrunning.Operations' => [ 26 | 'CancelOperation' => [ 27 | 'method' => 'post', 28 | 'uriTemplate' => '/v1/{name=operations/**}:cancel', 29 | 'body' => '*', 30 | 'placeholders' => [ 31 | 'name' => [ 32 | 'getters' => [ 33 | 'getName', 34 | ], 35 | ], 36 | ], 37 | ], 38 | 'DeleteOperation' => [ 39 | 'method' => 'delete', 40 | 'uriTemplate' => '/v1/{name=operations/**}', 41 | 'placeholders' => [ 42 | 'name' => [ 43 | 'getters' => [ 44 | 'getName', 45 | ], 46 | ], 47 | ], 48 | ], 49 | 'GetOperation' => [ 50 | 'method' => 'get', 51 | 'uriTemplate' => '/v1/{name=operations/**}', 52 | 'placeholders' => [ 53 | 'name' => [ 54 | 'getters' => [ 55 | 'getName', 56 | ], 57 | ], 58 | ], 59 | ], 60 | 'ListOperations' => [ 61 | 'method' => 'get', 62 | 'uriTemplate' => '/v1/{name=operations}', 63 | 'placeholders' => [ 64 | 'name' => [ 65 | 'getters' => [ 66 | 'getName', 67 | ], 68 | ], 69 | ], 70 | 'queryParams' => [ 71 | 'filter', 72 | ], 73 | ], 74 | ], 75 | ], 76 | ]; 77 | -------------------------------------------------------------------------------- /src/LongRunning/resources/operations_descriptor_config.php: -------------------------------------------------------------------------------- 1 | [ 25 | 'google.longrunning.Operations' => [ 26 | 'CancelOperation' => [ 27 | 'callType' => \Google\ApiCore\Call::UNARY_CALL, 28 | 'responseType' => 'Google\Protobuf\GPBEmpty', 29 | 'headerParams' => [ 30 | [ 31 | 'keyName' => 'name', 32 | 'fieldAccessors' => [ 33 | 'getName', 34 | ], 35 | ], 36 | ], 37 | ], 38 | 'DeleteOperation' => [ 39 | 'callType' => \Google\ApiCore\Call::UNARY_CALL, 40 | 'responseType' => 'Google\Protobuf\GPBEmpty', 41 | 'headerParams' => [ 42 | [ 43 | 'keyName' => 'name', 44 | 'fieldAccessors' => [ 45 | 'getName', 46 | ], 47 | ], 48 | ], 49 | ], 50 | 'GetOperation' => [ 51 | 'callType' => \Google\ApiCore\Call::UNARY_CALL, 52 | 'responseType' => 'Google\LongRunning\Operation', 53 | 'headerParams' => [ 54 | [ 55 | 'keyName' => 'name', 56 | 'fieldAccessors' => [ 57 | 'getName', 58 | ], 59 | ], 60 | ], 61 | ], 62 | 'ListOperations' => [ 63 | 'pageStreaming' => [ 64 | 'requestPageTokenGetMethod' => 'getPageToken', 65 | 'requestPageTokenSetMethod' => 'setPageToken', 66 | 'requestPageSizeGetMethod' => 'getPageSize', 67 | 'requestPageSizeSetMethod' => 'setPageSize', 68 | 'responsePageTokenGetMethod' => 'getNextPageToken', 69 | 'resourcesGetMethod' => 'getOperations', 70 | ], 71 | 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, 72 | 'responseType' => 'Google\LongRunning\ListOperationsResponse', 73 | 'headerParams' => [ 74 | [ 75 | 'keyName' => 'name', 76 | 'fieldAccessors' => [ 77 | 'getName', 78 | ], 79 | ], 80 | ], 81 | ], 82 | 'WaitOperation' => [ 83 | 'callType' => \Google\ApiCore\Call::UNARY_CALL, 84 | 'responseType' => 'Google\LongRunning\Operation', 85 | ], 86 | ], 87 | ], 88 | ]; 89 | -------------------------------------------------------------------------------- /src/LongRunning/WaitOperationRequest.php: -------------------------------------------------------------------------------- 1 | google.longrunning.WaitOperationRequest 16 | */ 17 | class WaitOperationRequest extends \Google\Protobuf\Internal\Message 18 | { 19 | /** 20 | * The name of the operation resource to wait on. 21 | * 22 | * Generated from protobuf field string name = 1; 23 | */ 24 | private $name = ''; 25 | /** 26 | * The maximum duration to wait before timing out. If left blank, the wait 27 | * will be at most the time permitted by the underlying HTTP/RPC protocol. 28 | * If RPC context deadline is also specified, the shorter one will be used. 29 | * 30 | * Generated from protobuf field .google.protobuf.Duration timeout = 2; 31 | */ 32 | private $timeout = null; 33 | 34 | /** 35 | * Constructor. 36 | * 37 | * @param array $data { 38 | * Optional. Data for populating the Message object. 39 | * 40 | * @type string $name 41 | * The name of the operation resource to wait on. 42 | * @type \Google\Protobuf\Duration $timeout 43 | * The maximum duration to wait before timing out. If left blank, the wait 44 | * will be at most the time permitted by the underlying HTTP/RPC protocol. 45 | * If RPC context deadline is also specified, the shorter one will be used. 46 | * } 47 | */ 48 | public function __construct($data = NULL) { 49 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 50 | parent::__construct($data); 51 | } 52 | 53 | /** 54 | * The name of the operation resource to wait on. 55 | * 56 | * Generated from protobuf field string name = 1; 57 | * @return string 58 | */ 59 | public function getName() 60 | { 61 | return $this->name; 62 | } 63 | 64 | /** 65 | * The name of the operation resource to wait on. 66 | * 67 | * Generated from protobuf field string name = 1; 68 | * @param string $var 69 | * @return $this 70 | */ 71 | public function setName($var) 72 | { 73 | GPBUtil::checkString($var, True); 74 | $this->name = $var; 75 | 76 | return $this; 77 | } 78 | 79 | /** 80 | * The maximum duration to wait before timing out. If left blank, the wait 81 | * will be at most the time permitted by the underlying HTTP/RPC protocol. 82 | * If RPC context deadline is also specified, the shorter one will be used. 83 | * 84 | * Generated from protobuf field .google.protobuf.Duration timeout = 2; 85 | * @return \Google\Protobuf\Duration|null 86 | */ 87 | public function getTimeout() 88 | { 89 | return $this->timeout; 90 | } 91 | 92 | public function hasTimeout() 93 | { 94 | return isset($this->timeout); 95 | } 96 | 97 | public function clearTimeout() 98 | { 99 | unset($this->timeout); 100 | } 101 | 102 | /** 103 | * The maximum duration to wait before timing out. If left blank, the wait 104 | * will be at most the time permitted by the underlying HTTP/RPC protocol. 105 | * If RPC context deadline is also specified, the shorter one will be used. 106 | * 107 | * Generated from protobuf field .google.protobuf.Duration timeout = 2; 108 | * @param \Google\Protobuf\Duration $var 109 | * @return $this 110 | */ 111 | public function setTimeout($var) 112 | { 113 | GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); 114 | $this->timeout = $var; 115 | 116 | return $this; 117 | } 118 | 119 | } 120 | 121 | -------------------------------------------------------------------------------- /src/LongRunning/ListOperationsResponse.php: -------------------------------------------------------------------------------- 1 | google.longrunning.ListOperationsResponse 16 | */ 17 | class ListOperationsResponse extends \Google\Protobuf\Internal\Message 18 | { 19 | /** 20 | * A list of operations that matches the specified filter in the request. 21 | * 22 | * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; 23 | */ 24 | private $operations; 25 | /** 26 | * The standard List next-page token. 27 | * 28 | * Generated from protobuf field string next_page_token = 2; 29 | */ 30 | private $next_page_token = ''; 31 | /** 32 | * Unordered list. Unreachable resources. Populated when the request sets 33 | * `ListOperationsRequest.return_partial_success` and reads across 34 | * collections e.g. when attempting to list all resources across all supported 35 | * locations. 36 | * 37 | * Generated from protobuf field repeated string unreachable = 3 [(.google.api.field_behavior) = UNORDERED_LIST]; 38 | */ 39 | private $unreachable; 40 | 41 | /** 42 | * Constructor. 43 | * 44 | * @param array $data { 45 | * Optional. Data for populating the Message object. 46 | * 47 | * @type array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $operations 48 | * A list of operations that matches the specified filter in the request. 49 | * @type string $next_page_token 50 | * The standard List next-page token. 51 | * @type array|\Google\Protobuf\Internal\RepeatedField $unreachable 52 | * Unordered list. Unreachable resources. Populated when the request sets 53 | * `ListOperationsRequest.return_partial_success` and reads across 54 | * collections e.g. when attempting to list all resources across all supported 55 | * locations. 56 | * } 57 | */ 58 | public function __construct($data = NULL) { 59 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 60 | parent::__construct($data); 61 | } 62 | 63 | /** 64 | * A list of operations that matches the specified filter in the request. 65 | * 66 | * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; 67 | * @return \Google\Protobuf\Internal\RepeatedField 68 | */ 69 | public function getOperations() 70 | { 71 | return $this->operations; 72 | } 73 | 74 | /** 75 | * A list of operations that matches the specified filter in the request. 76 | * 77 | * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; 78 | * @param array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $var 79 | * @return $this 80 | */ 81 | public function setOperations($var) 82 | { 83 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\LongRunning\Operation::class); 84 | $this->operations = $arr; 85 | 86 | return $this; 87 | } 88 | 89 | /** 90 | * The standard List next-page token. 91 | * 92 | * Generated from protobuf field string next_page_token = 2; 93 | * @return string 94 | */ 95 | public function getNextPageToken() 96 | { 97 | return $this->next_page_token; 98 | } 99 | 100 | /** 101 | * The standard List next-page token. 102 | * 103 | * Generated from protobuf field string next_page_token = 2; 104 | * @param string $var 105 | * @return $this 106 | */ 107 | public function setNextPageToken($var) 108 | { 109 | GPBUtil::checkString($var, True); 110 | $this->next_page_token = $var; 111 | 112 | return $this; 113 | } 114 | 115 | /** 116 | * Unordered list. Unreachable resources. Populated when the request sets 117 | * `ListOperationsRequest.return_partial_success` and reads across 118 | * collections e.g. when attempting to list all resources across all supported 119 | * locations. 120 | * 121 | * Generated from protobuf field repeated string unreachable = 3 [(.google.api.field_behavior) = UNORDERED_LIST]; 122 | * @return \Google\Protobuf\Internal\RepeatedField 123 | */ 124 | public function getUnreachable() 125 | { 126 | return $this->unreachable; 127 | } 128 | 129 | /** 130 | * Unordered list. Unreachable resources. Populated when the request sets 131 | * `ListOperationsRequest.return_partial_success` and reads across 132 | * collections e.g. when attempting to list all resources across all supported 133 | * locations. 134 | * 135 | * Generated from protobuf field repeated string unreachable = 3 [(.google.api.field_behavior) = UNORDERED_LIST]; 136 | * @param array|\Google\Protobuf\Internal\RepeatedField $var 137 | * @return $this 138 | */ 139 | public function setUnreachable($var) 140 | { 141 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); 142 | $this->unreachable = $arr; 143 | 144 | return $this; 145 | } 146 | 147 | } 148 | 149 | -------------------------------------------------------------------------------- /src/LongRunning/OperationInfo.php: -------------------------------------------------------------------------------- 1 | google.longrunning.OperationInfo 22 | */ 23 | class OperationInfo extends \Google\Protobuf\Internal\Message 24 | { 25 | /** 26 | * Required. The message name of the primary return type for this 27 | * long-running operation. 28 | * This type will be used to deserialize the LRO's response. 29 | * If the response is in a different package from the rpc, a fully-qualified 30 | * message name must be used (e.g. `google.protobuf.Struct`). 31 | * Note: Altering this value constitutes a breaking change. 32 | * 33 | * Generated from protobuf field string response_type = 1; 34 | */ 35 | private $response_type = ''; 36 | /** 37 | * Required. The message name of the metadata type for this long-running 38 | * operation. 39 | * If the response is in a different package from the rpc, a fully-qualified 40 | * message name must be used (e.g. `google.protobuf.Struct`). 41 | * Note: Altering this value constitutes a breaking change. 42 | * 43 | * Generated from protobuf field string metadata_type = 2; 44 | */ 45 | private $metadata_type = ''; 46 | 47 | /** 48 | * Constructor. 49 | * 50 | * @param array $data { 51 | * Optional. Data for populating the Message object. 52 | * 53 | * @type string $response_type 54 | * Required. The message name of the primary return type for this 55 | * long-running operation. 56 | * This type will be used to deserialize the LRO's response. 57 | * If the response is in a different package from the rpc, a fully-qualified 58 | * message name must be used (e.g. `google.protobuf.Struct`). 59 | * Note: Altering this value constitutes a breaking change. 60 | * @type string $metadata_type 61 | * Required. The message name of the metadata type for this long-running 62 | * operation. 63 | * If the response is in a different package from the rpc, a fully-qualified 64 | * message name must be used (e.g. `google.protobuf.Struct`). 65 | * Note: Altering this value constitutes a breaking change. 66 | * } 67 | */ 68 | public function __construct($data = NULL) { 69 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 70 | parent::__construct($data); 71 | } 72 | 73 | /** 74 | * Required. The message name of the primary return type for this 75 | * long-running operation. 76 | * This type will be used to deserialize the LRO's response. 77 | * If the response is in a different package from the rpc, a fully-qualified 78 | * message name must be used (e.g. `google.protobuf.Struct`). 79 | * Note: Altering this value constitutes a breaking change. 80 | * 81 | * Generated from protobuf field string response_type = 1; 82 | * @return string 83 | */ 84 | public function getResponseType() 85 | { 86 | return $this->response_type; 87 | } 88 | 89 | /** 90 | * Required. The message name of the primary return type for this 91 | * long-running operation. 92 | * This type will be used to deserialize the LRO's response. 93 | * If the response is in a different package from the rpc, a fully-qualified 94 | * message name must be used (e.g. `google.protobuf.Struct`). 95 | * Note: Altering this value constitutes a breaking change. 96 | * 97 | * Generated from protobuf field string response_type = 1; 98 | * @param string $var 99 | * @return $this 100 | */ 101 | public function setResponseType($var) 102 | { 103 | GPBUtil::checkString($var, True); 104 | $this->response_type = $var; 105 | 106 | return $this; 107 | } 108 | 109 | /** 110 | * Required. The message name of the metadata type for this long-running 111 | * operation. 112 | * If the response is in a different package from the rpc, a fully-qualified 113 | * message name must be used (e.g. `google.protobuf.Struct`). 114 | * Note: Altering this value constitutes a breaking change. 115 | * 116 | * Generated from protobuf field string metadata_type = 2; 117 | * @return string 118 | */ 119 | public function getMetadataType() 120 | { 121 | return $this->metadata_type; 122 | } 123 | 124 | /** 125 | * Required. The message name of the metadata type for this long-running 126 | * operation. 127 | * If the response is in a different package from the rpc, a fully-qualified 128 | * message name must be used (e.g. `google.protobuf.Struct`). 129 | * Note: Altering this value constitutes a breaking change. 130 | * 131 | * Generated from protobuf field string metadata_type = 2; 132 | * @param string $var 133 | * @return $this 134 | */ 135 | public function setMetadataType($var) 136 | { 137 | GPBUtil::checkString($var, True); 138 | $this->metadata_type = $var; 139 | 140 | return $this; 141 | } 142 | 143 | } 144 | 145 | -------------------------------------------------------------------------------- /src/LongRunning/OperationsGrpcClient.php: -------------------------------------------------------------------------------- 1 | _simpleRequest('/google.longrunning.Operations/ListOperations', 62 | $argument, 63 | ['\Google\LongRunning\ListOperationsResponse', 'decode'], 64 | $metadata, $options); 65 | } 66 | 67 | /** 68 | * Gets the latest state of a long-running operation. Clients can use this 69 | * method to poll the operation result at intervals as recommended by the API 70 | * service. 71 | * @param \Google\LongRunning\GetOperationRequest $argument input argument 72 | * @param array $metadata metadata 73 | * @param array $options call options 74 | * @return \Grpc\UnaryCall 75 | */ 76 | public function GetOperation(\Google\LongRunning\GetOperationRequest $argument, 77 | $metadata = [], $options = []) { 78 | return $this->_simpleRequest('/google.longrunning.Operations/GetOperation', 79 | $argument, 80 | ['\Google\LongRunning\Operation', 'decode'], 81 | $metadata, $options); 82 | } 83 | 84 | /** 85 | * Deletes a long-running operation. This method indicates that the client is 86 | * no longer interested in the operation result. It does not cancel the 87 | * operation. If the server doesn't support this method, it returns 88 | * `google.rpc.Code.UNIMPLEMENTED`. 89 | * @param \Google\LongRunning\DeleteOperationRequest $argument input argument 90 | * @param array $metadata metadata 91 | * @param array $options call options 92 | * @return \Grpc\UnaryCall 93 | */ 94 | public function DeleteOperation(\Google\LongRunning\DeleteOperationRequest $argument, 95 | $metadata = [], $options = []) { 96 | return $this->_simpleRequest('/google.longrunning.Operations/DeleteOperation', 97 | $argument, 98 | ['\Google\Protobuf\GPBEmpty', 'decode'], 99 | $metadata, $options); 100 | } 101 | 102 | /** 103 | * Starts asynchronous cancellation on a long-running operation. The server 104 | * makes a best effort to cancel the operation, but success is not 105 | * guaranteed. If the server doesn't support this method, it returns 106 | * `google.rpc.Code.UNIMPLEMENTED`. Clients can use 107 | * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or 108 | * other methods to check whether the cancellation succeeded or whether the 109 | * operation completed despite cancellation. On successful cancellation, 110 | * the operation is not deleted; instead, it becomes an operation with 111 | * an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, 112 | * corresponding to `Code.CANCELLED`. 113 | * @param \Google\LongRunning\CancelOperationRequest $argument input argument 114 | * @param array $metadata metadata 115 | * @param array $options call options 116 | * @return \Grpc\UnaryCall 117 | */ 118 | public function CancelOperation(\Google\LongRunning\CancelOperationRequest $argument, 119 | $metadata = [], $options = []) { 120 | return $this->_simpleRequest('/google.longrunning.Operations/CancelOperation', 121 | $argument, 122 | ['\Google\Protobuf\GPBEmpty', 'decode'], 123 | $metadata, $options); 124 | } 125 | 126 | /** 127 | * Waits until the specified long-running operation is done or reaches at most 128 | * a specified timeout, returning the latest state. If the operation is 129 | * already done, the latest state is immediately returned. If the timeout 130 | * specified is greater than the default HTTP/RPC timeout, the HTTP/RPC 131 | * timeout is used. If the server does not support this method, it returns 132 | * `google.rpc.Code.UNIMPLEMENTED`. 133 | * Note that this method is on a best-effort basis. It may return the latest 134 | * state before the specified timeout (including immediately), meaning even an 135 | * immediate response is no guarantee that the operation is done. 136 | * @param \Google\LongRunning\WaitOperationRequest $argument input argument 137 | * @param array $metadata metadata 138 | * @param array $options call options 139 | * @return \Grpc\UnaryCall 140 | */ 141 | public function WaitOperation(\Google\LongRunning\WaitOperationRequest $argument, 142 | $metadata = [], $options = []) { 143 | return $this->_simpleRequest('/google.longrunning.Operations/WaitOperation', 144 | $argument, 145 | ['\Google\LongRunning\Operation', 'decode'], 146 | $metadata, $options); 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /src/LongRunning/ListOperationsRequest.php: -------------------------------------------------------------------------------- 1 | google.longrunning.ListOperationsRequest 16 | */ 17 | class ListOperationsRequest extends \Google\Protobuf\Internal\Message 18 | { 19 | /** 20 | * The name of the operation's parent resource. 21 | * 22 | * Generated from protobuf field string name = 4; 23 | */ 24 | private $name = ''; 25 | /** 26 | * The standard list filter. 27 | * 28 | * Generated from protobuf field string filter = 1; 29 | */ 30 | private $filter = ''; 31 | /** 32 | * The standard list page size. 33 | * 34 | * Generated from protobuf field int32 page_size = 2; 35 | */ 36 | private $page_size = 0; 37 | /** 38 | * The standard list page token. 39 | * 40 | * Generated from protobuf field string page_token = 3; 41 | */ 42 | private $page_token = ''; 43 | /** 44 | * When set to `true`, operations that are reachable are returned as normal, 45 | * and those that are unreachable are returned in the 46 | * [ListOperationsResponse.unreachable] field. 47 | * This can only be `true` when reading across collections e.g. when `parent` 48 | * is set to `"projects/example/locations/-"`. 49 | * This field is not by default supported and will result in an 50 | * `UNIMPLEMENTED` error if set unless explicitly documented otherwise in 51 | * service or product specific documentation. 52 | * 53 | * Generated from protobuf field bool return_partial_success = 5; 54 | */ 55 | private $return_partial_success = false; 56 | 57 | /** 58 | * @param string $name The name of the operation's parent resource. 59 | * @param string $filter The standard list filter. 60 | * 61 | * @return \Google\LongRunning\ListOperationsRequest 62 | * 63 | * @experimental 64 | */ 65 | public static function build(string $name, string $filter): self 66 | { 67 | return (new self()) 68 | ->setName($name) 69 | ->setFilter($filter); 70 | } 71 | 72 | /** 73 | * Constructor. 74 | * 75 | * @param array $data { 76 | * Optional. Data for populating the Message object. 77 | * 78 | * @type string $name 79 | * The name of the operation's parent resource. 80 | * @type string $filter 81 | * The standard list filter. 82 | * @type int $page_size 83 | * The standard list page size. 84 | * @type string $page_token 85 | * The standard list page token. 86 | * @type bool $return_partial_success 87 | * When set to `true`, operations that are reachable are returned as normal, 88 | * and those that are unreachable are returned in the 89 | * [ListOperationsResponse.unreachable] field. 90 | * This can only be `true` when reading across collections e.g. when `parent` 91 | * is set to `"projects/example/locations/-"`. 92 | * This field is not by default supported and will result in an 93 | * `UNIMPLEMENTED` error if set unless explicitly documented otherwise in 94 | * service or product specific documentation. 95 | * } 96 | */ 97 | public function __construct($data = NULL) { 98 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 99 | parent::__construct($data); 100 | } 101 | 102 | /** 103 | * The name of the operation's parent resource. 104 | * 105 | * Generated from protobuf field string name = 4; 106 | * @return string 107 | */ 108 | public function getName() 109 | { 110 | return $this->name; 111 | } 112 | 113 | /** 114 | * The name of the operation's parent resource. 115 | * 116 | * Generated from protobuf field string name = 4; 117 | * @param string $var 118 | * @return $this 119 | */ 120 | public function setName($var) 121 | { 122 | GPBUtil::checkString($var, True); 123 | $this->name = $var; 124 | 125 | return $this; 126 | } 127 | 128 | /** 129 | * The standard list filter. 130 | * 131 | * Generated from protobuf field string filter = 1; 132 | * @return string 133 | */ 134 | public function getFilter() 135 | { 136 | return $this->filter; 137 | } 138 | 139 | /** 140 | * The standard list filter. 141 | * 142 | * Generated from protobuf field string filter = 1; 143 | * @param string $var 144 | * @return $this 145 | */ 146 | public function setFilter($var) 147 | { 148 | GPBUtil::checkString($var, True); 149 | $this->filter = $var; 150 | 151 | return $this; 152 | } 153 | 154 | /** 155 | * The standard list page size. 156 | * 157 | * Generated from protobuf field int32 page_size = 2; 158 | * @return int 159 | */ 160 | public function getPageSize() 161 | { 162 | return $this->page_size; 163 | } 164 | 165 | /** 166 | * The standard list page size. 167 | * 168 | * Generated from protobuf field int32 page_size = 2; 169 | * @param int $var 170 | * @return $this 171 | */ 172 | public function setPageSize($var) 173 | { 174 | GPBUtil::checkInt32($var); 175 | $this->page_size = $var; 176 | 177 | return $this; 178 | } 179 | 180 | /** 181 | * The standard list page token. 182 | * 183 | * Generated from protobuf field string page_token = 3; 184 | * @return string 185 | */ 186 | public function getPageToken() 187 | { 188 | return $this->page_token; 189 | } 190 | 191 | /** 192 | * The standard list page token. 193 | * 194 | * Generated from protobuf field string page_token = 3; 195 | * @param string $var 196 | * @return $this 197 | */ 198 | public function setPageToken($var) 199 | { 200 | GPBUtil::checkString($var, True); 201 | $this->page_token = $var; 202 | 203 | return $this; 204 | } 205 | 206 | /** 207 | * When set to `true`, operations that are reachable are returned as normal, 208 | * and those that are unreachable are returned in the 209 | * [ListOperationsResponse.unreachable] field. 210 | * This can only be `true` when reading across collections e.g. when `parent` 211 | * is set to `"projects/example/locations/-"`. 212 | * This field is not by default supported and will result in an 213 | * `UNIMPLEMENTED` error if set unless explicitly documented otherwise in 214 | * service or product specific documentation. 215 | * 216 | * Generated from protobuf field bool return_partial_success = 5; 217 | * @return bool 218 | */ 219 | public function getReturnPartialSuccess() 220 | { 221 | return $this->return_partial_success; 222 | } 223 | 224 | /** 225 | * When set to `true`, operations that are reachable are returned as normal, 226 | * and those that are unreachable are returned in the 227 | * [ListOperationsResponse.unreachable] field. 228 | * This can only be `true` when reading across collections e.g. when `parent` 229 | * is set to `"projects/example/locations/-"`. 230 | * This field is not by default supported and will result in an 231 | * `UNIMPLEMENTED` error if set unless explicitly documented otherwise in 232 | * service or product specific documentation. 233 | * 234 | * Generated from protobuf field bool return_partial_success = 5; 235 | * @param bool $var 236 | * @return $this 237 | */ 238 | public function setReturnPartialSuccess($var) 239 | { 240 | GPBUtil::checkBool($var); 241 | $this->return_partial_success = $var; 242 | 243 | return $this; 244 | } 245 | 246 | } 247 | 248 | -------------------------------------------------------------------------------- /src/LongRunning/Operation.php: -------------------------------------------------------------------------------- 1 | google.longrunning.Operation 16 | */ 17 | class Operation extends \Google\Protobuf\Internal\Message 18 | { 19 | /** 20 | * The server-assigned name, which is only unique within the same service that 21 | * originally returns it. If you use the default HTTP mapping, the 22 | * `name` should be a resource name ending with `operations/{unique_id}`. 23 | * 24 | * Generated from protobuf field string name = 1; 25 | */ 26 | private $name = ''; 27 | /** 28 | * Service-specific metadata associated with the operation. It typically 29 | * contains progress information and common metadata such as create time. 30 | * Some services might not provide such metadata. Any method that returns a 31 | * long-running operation should document the metadata type, if any. 32 | * 33 | * Generated from protobuf field .google.protobuf.Any metadata = 2; 34 | */ 35 | private $metadata = null; 36 | /** 37 | * If the value is `false`, it means the operation is still in progress. 38 | * If `true`, the operation is completed, and either `error` or `response` is 39 | * available. 40 | * 41 | * Generated from protobuf field bool done = 3; 42 | */ 43 | private $done = false; 44 | protected $result; 45 | 46 | /** 47 | * Constructor. 48 | * 49 | * @param array $data { 50 | * Optional. Data for populating the Message object. 51 | * 52 | * @type string $name 53 | * The server-assigned name, which is only unique within the same service that 54 | * originally returns it. If you use the default HTTP mapping, the 55 | * `name` should be a resource name ending with `operations/{unique_id}`. 56 | * @type \Google\Protobuf\Any $metadata 57 | * Service-specific metadata associated with the operation. It typically 58 | * contains progress information and common metadata such as create time. 59 | * Some services might not provide such metadata. Any method that returns a 60 | * long-running operation should document the metadata type, if any. 61 | * @type bool $done 62 | * If the value is `false`, it means the operation is still in progress. 63 | * If `true`, the operation is completed, and either `error` or `response` is 64 | * available. 65 | * @type \Google\Rpc\Status $error 66 | * The error result of the operation in case of failure or cancellation. 67 | * @type \Google\Protobuf\Any $response 68 | * The normal, successful response of the operation. If the original 69 | * method returns no data on success, such as `Delete`, the response is 70 | * `google.protobuf.Empty`. If the original method is standard 71 | * `Get`/`Create`/`Update`, the response should be the resource. For other 72 | * methods, the response should have the type `XxxResponse`, where `Xxx` 73 | * is the original method name. For example, if the original method name 74 | * is `TakeSnapshot()`, the inferred response type is 75 | * `TakeSnapshotResponse`. 76 | * } 77 | */ 78 | public function __construct($data = NULL) { 79 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 80 | parent::__construct($data); 81 | } 82 | 83 | /** 84 | * The server-assigned name, which is only unique within the same service that 85 | * originally returns it. If you use the default HTTP mapping, the 86 | * `name` should be a resource name ending with `operations/{unique_id}`. 87 | * 88 | * Generated from protobuf field string name = 1; 89 | * @return string 90 | */ 91 | public function getName() 92 | { 93 | return $this->name; 94 | } 95 | 96 | /** 97 | * The server-assigned name, which is only unique within the same service that 98 | * originally returns it. If you use the default HTTP mapping, the 99 | * `name` should be a resource name ending with `operations/{unique_id}`. 100 | * 101 | * Generated from protobuf field string name = 1; 102 | * @param string $var 103 | * @return $this 104 | */ 105 | public function setName($var) 106 | { 107 | GPBUtil::checkString($var, True); 108 | $this->name = $var; 109 | 110 | return $this; 111 | } 112 | 113 | /** 114 | * Service-specific metadata associated with the operation. It typically 115 | * contains progress information and common metadata such as create time. 116 | * Some services might not provide such metadata. Any method that returns a 117 | * long-running operation should document the metadata type, if any. 118 | * 119 | * Generated from protobuf field .google.protobuf.Any metadata = 2; 120 | * @return \Google\Protobuf\Any|null 121 | */ 122 | public function getMetadata() 123 | { 124 | return $this->metadata; 125 | } 126 | 127 | public function hasMetadata() 128 | { 129 | return isset($this->metadata); 130 | } 131 | 132 | public function clearMetadata() 133 | { 134 | unset($this->metadata); 135 | } 136 | 137 | /** 138 | * Service-specific metadata associated with the operation. It typically 139 | * contains progress information and common metadata such as create time. 140 | * Some services might not provide such metadata. Any method that returns a 141 | * long-running operation should document the metadata type, if any. 142 | * 143 | * Generated from protobuf field .google.protobuf.Any metadata = 2; 144 | * @param \Google\Protobuf\Any $var 145 | * @return $this 146 | */ 147 | public function setMetadata($var) 148 | { 149 | GPBUtil::checkMessage($var, \Google\Protobuf\Any::class); 150 | $this->metadata = $var; 151 | 152 | return $this; 153 | } 154 | 155 | /** 156 | * If the value is `false`, it means the operation is still in progress. 157 | * If `true`, the operation is completed, and either `error` or `response` is 158 | * available. 159 | * 160 | * Generated from protobuf field bool done = 3; 161 | * @return bool 162 | */ 163 | public function getDone() 164 | { 165 | return $this->done; 166 | } 167 | 168 | /** 169 | * If the value is `false`, it means the operation is still in progress. 170 | * If `true`, the operation is completed, and either `error` or `response` is 171 | * available. 172 | * 173 | * Generated from protobuf field bool done = 3; 174 | * @param bool $var 175 | * @return $this 176 | */ 177 | public function setDone($var) 178 | { 179 | GPBUtil::checkBool($var); 180 | $this->done = $var; 181 | 182 | return $this; 183 | } 184 | 185 | /** 186 | * The error result of the operation in case of failure or cancellation. 187 | * 188 | * Generated from protobuf field .google.rpc.Status error = 4; 189 | * @return \Google\Rpc\Status|null 190 | */ 191 | public function getError() 192 | { 193 | return $this->readOneof(4); 194 | } 195 | 196 | public function hasError() 197 | { 198 | return $this->hasOneof(4); 199 | } 200 | 201 | /** 202 | * The error result of the operation in case of failure or cancellation. 203 | * 204 | * Generated from protobuf field .google.rpc.Status error = 4; 205 | * @param \Google\Rpc\Status $var 206 | * @return $this 207 | */ 208 | public function setError($var) 209 | { 210 | GPBUtil::checkMessage($var, \Google\Rpc\Status::class); 211 | $this->writeOneof(4, $var); 212 | 213 | return $this; 214 | } 215 | 216 | /** 217 | * The normal, successful response of the operation. If the original 218 | * method returns no data on success, such as `Delete`, the response is 219 | * `google.protobuf.Empty`. If the original method is standard 220 | * `Get`/`Create`/`Update`, the response should be the resource. For other 221 | * methods, the response should have the type `XxxResponse`, where `Xxx` 222 | * is the original method name. For example, if the original method name 223 | * is `TakeSnapshot()`, the inferred response type is 224 | * `TakeSnapshotResponse`. 225 | * 226 | * Generated from protobuf field .google.protobuf.Any response = 5; 227 | * @return \Google\Protobuf\Any|null 228 | */ 229 | public function getResponse() 230 | { 231 | return $this->readOneof(5); 232 | } 233 | 234 | public function hasResponse() 235 | { 236 | return $this->hasOneof(5); 237 | } 238 | 239 | /** 240 | * The normal, successful response of the operation. If the original 241 | * method returns no data on success, such as `Delete`, the response is 242 | * `google.protobuf.Empty`. If the original method is standard 243 | * `Get`/`Create`/`Update`, the response should be the resource. For other 244 | * methods, the response should have the type `XxxResponse`, where `Xxx` 245 | * is the original method name. For example, if the original method name 246 | * is `TakeSnapshot()`, the inferred response type is 247 | * `TakeSnapshotResponse`. 248 | * 249 | * Generated from protobuf field .google.protobuf.Any response = 5; 250 | * @param \Google\Protobuf\Any $var 251 | * @return $this 252 | */ 253 | public function setResponse($var) 254 | { 255 | GPBUtil::checkMessage($var, \Google\Protobuf\Any::class); 256 | $this->writeOneof(5, $var); 257 | 258 | return $this; 259 | } 260 | 261 | /** 262 | * @return string 263 | */ 264 | public function getResult() 265 | { 266 | return $this->whichOneof("result"); 267 | } 268 | 269 | } 270 | 271 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /src/LongRunning/Client/OperationsClient.php: -------------------------------------------------------------------------------- 1 | cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = []) 60 | * @method PromiseInterface deleteOperationAsync(DeleteOperationRequest $request, array $optionalArgs = []) 61 | * @method PromiseInterface getOperationAsync(GetOperationRequest $request, array $optionalArgs = []) 62 | * @method PromiseInterface listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = []) 63 | * @method PromiseInterface waitOperationAsync(WaitOperationRequest $request, array $optionalArgs = []) 64 | */ 65 | class OperationsClient 66 | { 67 | use GapicClientTrait; 68 | 69 | /** The name of the service. */ 70 | private const SERVICE_NAME = 'google.longrunning.Operations'; 71 | 72 | /** 73 | * The default address of the service. 74 | * 75 | * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. 76 | */ 77 | private const SERVICE_ADDRESS = 'longrunning.googleapis.com'; 78 | 79 | /** The address template of the service. */ 80 | private const SERVICE_ADDRESS_TEMPLATE = 'longrunning.UNIVERSE_DOMAIN'; 81 | 82 | /** The default port of the service. */ 83 | private const DEFAULT_SERVICE_PORT = 443; 84 | 85 | /** The name of the code generator, to be included in the agent header. */ 86 | private const CODEGEN_NAME = 'gapic'; 87 | 88 | /** The default scopes required by the service. */ 89 | public static $serviceScopes = []; 90 | 91 | private static function getClientDefaults() 92 | { 93 | return [ 94 | 'serviceName' => self::SERVICE_NAME, 95 | 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, 96 | 'clientConfig' => __DIR__ . '/../resources/operations_client_config.json', 97 | 'descriptorsConfigPath' => __DIR__ . '/../resources/operations_descriptor_config.php', 98 | 'gcpApiConfigPath' => __DIR__ . '/../resources/operations_grpc_config.json', 99 | 'credentialsConfig' => [ 100 | 'defaultScopes' => self::$serviceScopes, 101 | ], 102 | 'transportConfig' => [ 103 | 'rest' => [ 104 | 'restClientConfigPath' => __DIR__ . '/../resources/operations_rest_client_config.php', 105 | ], 106 | ], 107 | ]; 108 | } 109 | 110 | /** 111 | * Constructor. 112 | * 113 | * @param array|ClientOptions $options { 114 | * Optional. Options for configuring the service API wrapper. 115 | * 116 | * @type string $apiEndpoint 117 | * The address of the API remote host. May optionally include the port, formatted 118 | * as ":". Default 'longrunning.googleapis.com:443'. 119 | * @type FetchAuthTokenInterface|CredentialsWrapper $credentials 120 | * This option should only be used with a pre-constructed 121 | * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that 122 | * when one of these objects are provided, any settings in $credentialsConfig will 123 | * be ignored. 124 | * **Important**: If you are providing a path to a credentials file, or a decoded 125 | * credentials file as a PHP array, this usage is now DEPRECATED. Providing an 126 | * unvalidated credential configuration to Google APIs can compromise the security 127 | * of your systems and data. It is recommended to create the credentials explicitly 128 | * ``` 129 | * use Google\Auth\Credentials\ServiceAccountCredentials; 130 | * use Google\LongRunning\OperationsClient; 131 | * $creds = new ServiceAccountCredentials($scopes, $json); 132 | * $options = new OperationsClient(['credentials' => $creds]); 133 | * ``` 134 | * {@see 135 | * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} 136 | * @type array $credentialsConfig 137 | * Options used to configure credentials, including auth token caching, for the 138 | * client. For a full list of supporting configuration options, see 139 | * {@see \Google\ApiCore\CredentialsWrapper::build()} . 140 | * @type bool $disableRetries 141 | * Determines whether or not retries defined by the client configuration should be 142 | * disabled. Defaults to `false`. 143 | * @type string|array $clientConfig 144 | * Client method configuration, including retry settings. This option can be either 145 | * a path to a JSON file, or a PHP array containing the decoded JSON data. By 146 | * default this settings points to the default client config file, which is 147 | * provided in the resources folder. 148 | * @type string|TransportInterface $transport 149 | * The transport used for executing network requests. May be either the string 150 | * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. 151 | * *Advanced usage*: Additionally, it is possible to pass in an already 152 | * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note 153 | * that when this object is provided, any settings in $transportConfig, and any 154 | * $apiEndpoint setting, will be ignored. 155 | * @type array $transportConfig 156 | * Configuration options that will be used to construct the transport. Options for 157 | * each supported transport type should be passed in a key for that transport. For 158 | * example: 159 | * $transportConfig = [ 160 | * 'grpc' => [...], 161 | * 'rest' => [...], 162 | * ]; 163 | * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and 164 | * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the 165 | * supported options. 166 | * @type callable $clientCertSource 167 | * A callable which returns the client cert as a string. This can be used to 168 | * provide a certificate and private key to the transport layer for mTLS. 169 | * @type false|LoggerInterface $logger 170 | * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 171 | * 'GOOGLE_SDK_PHP_LOGGING' environment flag 172 | * @type string $universeDomain 173 | * The service domain for the client. Defaults to 'googleapis.com'. 174 | * } 175 | * 176 | * @throws ValidationException 177 | */ 178 | public function __construct(array|ClientOptions $options = []) 179 | { 180 | $clientOptions = $this->buildClientOptions($options); 181 | $this->setClientOptions($clientOptions); 182 | } 183 | 184 | /** Handles execution of the async variants for each documented method. */ 185 | public function __call($method, $args) 186 | { 187 | if (substr($method, -5) !== 'Async') { 188 | trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); 189 | } 190 | 191 | array_unshift($args, substr($method, 0, -5)); 192 | return call_user_func_array([$this, 'startAsyncCall'], $args); 193 | } 194 | 195 | /** 196 | * Starts asynchronous cancellation on a long-running operation. The server 197 | * makes a best effort to cancel the operation, but success is not 198 | * guaranteed. If the server doesn't support this method, it returns 199 | * `google.rpc.Code.UNIMPLEMENTED`. Clients can use 200 | * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or 201 | * other methods to check whether the cancellation succeeded or whether the 202 | * operation completed despite cancellation. On successful cancellation, 203 | * the operation is not deleted; instead, it becomes an operation with 204 | * an [Operation.error][google.longrunning.Operation.error] value with a 205 | * [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to 206 | * `Code.CANCELLED`. 207 | * 208 | * The async variant is {@see OperationsClient::cancelOperationAsync()} . 209 | * 210 | * @example samples/OperationsClient/cancel_operation.php 211 | * 212 | * @param CancelOperationRequest $request A request to house fields associated with the call. 213 | * @param array $callOptions { 214 | * Optional. 215 | * 216 | * @type RetrySettings|array $retrySettings 217 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 218 | * associative array of retry settings parameters. See the documentation on 219 | * {@see RetrySettings} for example usage. 220 | * } 221 | * 222 | * @throws ApiException Thrown if the API call fails. 223 | */ 224 | public function cancelOperation(CancelOperationRequest $request, array $callOptions = []): void 225 | { 226 | $this->startApiCall('CancelOperation', $request, $callOptions)->wait(); 227 | } 228 | 229 | /** 230 | * Deletes a long-running operation. This method indicates that the client is 231 | * no longer interested in the operation result. It does not cancel the 232 | * operation. If the server doesn't support this method, it returns 233 | * `google.rpc.Code.UNIMPLEMENTED`. 234 | * 235 | * The async variant is {@see OperationsClient::deleteOperationAsync()} . 236 | * 237 | * @example samples/OperationsClient/delete_operation.php 238 | * 239 | * @param DeleteOperationRequest $request A request to house fields associated with the call. 240 | * @param array $callOptions { 241 | * Optional. 242 | * 243 | * @type RetrySettings|array $retrySettings 244 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 245 | * associative array of retry settings parameters. See the documentation on 246 | * {@see RetrySettings} for example usage. 247 | * } 248 | * 249 | * @throws ApiException Thrown if the API call fails. 250 | */ 251 | public function deleteOperation(DeleteOperationRequest $request, array $callOptions = []): void 252 | { 253 | $this->startApiCall('DeleteOperation', $request, $callOptions)->wait(); 254 | } 255 | 256 | /** 257 | * Gets the latest state of a long-running operation. Clients can use this 258 | * method to poll the operation result at intervals as recommended by the API 259 | * service. 260 | * 261 | * The async variant is {@see OperationsClient::getOperationAsync()} . 262 | * 263 | * @example samples/OperationsClient/get_operation.php 264 | * 265 | * @param GetOperationRequest $request A request to house fields associated with the call. 266 | * @param array $callOptions { 267 | * Optional. 268 | * 269 | * @type RetrySettings|array $retrySettings 270 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 271 | * associative array of retry settings parameters. See the documentation on 272 | * {@see RetrySettings} for example usage. 273 | * } 274 | * 275 | * @return Operation 276 | * 277 | * @throws ApiException Thrown if the API call fails. 278 | */ 279 | public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation 280 | { 281 | return $this->startApiCall('GetOperation', $request, $callOptions)->wait(); 282 | } 283 | 284 | /** 285 | * Lists operations that match the specified filter in the request. If the 286 | * server doesn't support this method, it returns `UNIMPLEMENTED`. 287 | * 288 | * The async variant is {@see OperationsClient::listOperationsAsync()} . 289 | * 290 | * @example samples/OperationsClient/list_operations.php 291 | * 292 | * @param ListOperationsRequest $request A request to house fields associated with the call. 293 | * @param array $callOptions { 294 | * Optional. 295 | * 296 | * @type RetrySettings|array $retrySettings 297 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 298 | * associative array of retry settings parameters. See the documentation on 299 | * {@see RetrySettings} for example usage. 300 | * } 301 | * 302 | * @return PagedListResponse 303 | * 304 | * @throws ApiException Thrown if the API call fails. 305 | */ 306 | public function listOperations(ListOperationsRequest $request, array $callOptions = []): PagedListResponse 307 | { 308 | return $this->startApiCall('ListOperations', $request, $callOptions); 309 | } 310 | 311 | /** 312 | * Waits until the specified long-running operation is done or reaches at most 313 | * a specified timeout, returning the latest state. If the operation is 314 | * already done, the latest state is immediately returned. If the timeout 315 | * specified is greater than the default HTTP/RPC timeout, the HTTP/RPC 316 | * timeout is used. If the server does not support this method, it returns 317 | * `google.rpc.Code.UNIMPLEMENTED`. 318 | * Note that this method is on a best-effort basis. It may return the latest 319 | * state before the specified timeout (including immediately), meaning even an 320 | * immediate response is no guarantee that the operation is done. 321 | * 322 | * The async variant is {@see OperationsClient::waitOperationAsync()} . 323 | * 324 | * @example samples/OperationsClient/wait_operation.php 325 | * 326 | * @param WaitOperationRequest $request A request to house fields associated with the call. 327 | * @param array $callOptions { 328 | * Optional. 329 | * 330 | * @type RetrySettings|array $retrySettings 331 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 332 | * associative array of retry settings parameters. See the documentation on 333 | * {@see RetrySettings} for example usage. 334 | * } 335 | * 336 | * @return Operation 337 | * 338 | * @throws ApiException Thrown if the API call fails. 339 | */ 340 | public function waitOperation(WaitOperationRequest $request, array $callOptions = []): Operation 341 | { 342 | return $this->startApiCall('WaitOperation', $request, $callOptions)->wait(); 343 | } 344 | } 345 | -------------------------------------------------------------------------------- /src/LongRunning/Gapic/OperationsGapicClient.php: -------------------------------------------------------------------------------- 1 | cancelOperation($name); 64 | * } finally { 65 | * $operationsClient->close(); 66 | * } 67 | * ``` 68 | * 69 | * @deprecated Please use the new service client {@see \Google\LongRunning\Client\OperationsClient}. 70 | */ 71 | class OperationsGapicClient 72 | { 73 | use GapicClientTrait; 74 | 75 | /** The name of the service. */ 76 | const SERVICE_NAME = 'google.longrunning.Operations'; 77 | 78 | /** 79 | * The default address of the service. 80 | * 81 | * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. 82 | */ 83 | const SERVICE_ADDRESS = 'longrunning.googleapis.com'; 84 | 85 | /** The address template of the service. */ 86 | private const SERVICE_ADDRESS_TEMPLATE = 'longrunning.UNIVERSE_DOMAIN'; 87 | 88 | /** The default port of the service. */ 89 | const DEFAULT_SERVICE_PORT = 443; 90 | 91 | /** The name of the code generator, to be included in the agent header. */ 92 | const CODEGEN_NAME = 'gapic'; 93 | 94 | /** The default scopes required by the service. */ 95 | public static $serviceScopes = []; 96 | 97 | private static function getClientDefaults() 98 | { 99 | return [ 100 | 'serviceName' => self::SERVICE_NAME, 101 | 'apiEndpoint' => 102 | self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, 103 | 'clientConfig' => 104 | __DIR__ . '/../resources/operations_client_config.json', 105 | 'descriptorsConfigPath' => 106 | __DIR__ . '/../resources/operations_descriptor_config.php', 107 | 'gcpApiConfigPath' => 108 | __DIR__ . '/../resources/operations_grpc_config.json', 109 | 'credentialsConfig' => [ 110 | 'defaultScopes' => self::$serviceScopes, 111 | ], 112 | 'transportConfig' => [ 113 | 'rest' => [ 114 | 'restClientConfigPath' => 115 | __DIR__ . 116 | '/../resources/operations_rest_client_config.php', 117 | ], 118 | ], 119 | ]; 120 | } 121 | 122 | /** 123 | * Constructor. 124 | * 125 | * @param array $options { 126 | * Optional. Options for configuring the service API wrapper. 127 | * 128 | * @type string $apiEndpoint 129 | * The address of the API remote host. May optionally include the port, formatted 130 | * as ":". Default 'longrunning.googleapis.com:443'. 131 | * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials 132 | * The credentials to be used by the client to authorize API calls. This option 133 | * accepts either a path to a credentials file, or a decoded credentials file as a 134 | * PHP array. 135 | * *Advanced usage*: In addition, this option can also accept a pre-constructed 136 | * {@see \Google\Auth\FetchAuthTokenInterface} object or 137 | * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these 138 | * objects are provided, any settings in $credentialsConfig will be ignored. 139 | * @type array $credentialsConfig 140 | * Options used to configure credentials, including auth token caching, for the 141 | * client. For a full list of supporting configuration options, see 142 | * {@see \Google\ApiCore\CredentialsWrapper::build()} . 143 | * @type bool $disableRetries 144 | * Determines whether or not retries defined by the client configuration should be 145 | * disabled. Defaults to `false`. 146 | * @type string|array $clientConfig 147 | * Client method configuration, including retry settings. This option can be either 148 | * a path to a JSON file, or a PHP array containing the decoded JSON data. By 149 | * default this settings points to the default client config file, which is 150 | * provided in the resources folder. 151 | * @type string|TransportInterface $transport 152 | * The transport used for executing network requests. May be either the string 153 | * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. 154 | * *Advanced usage*: Additionally, it is possible to pass in an already 155 | * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note 156 | * that when this object is provided, any settings in $transportConfig, and any 157 | * $apiEndpoint setting, will be ignored. 158 | * @type array $transportConfig 159 | * Configuration options that will be used to construct the transport. Options for 160 | * each supported transport type should be passed in a key for that transport. For 161 | * example: 162 | * $transportConfig = [ 163 | * 'grpc' => [...], 164 | * 'rest' => [...], 165 | * ]; 166 | * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and 167 | * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the 168 | * supported options. 169 | * @type callable $clientCertSource 170 | * A callable which returns the client cert as a string. This can be used to 171 | * provide a certificate and private key to the transport layer for mTLS. 172 | * } 173 | * 174 | * @throws ValidationException 175 | */ 176 | public function __construct(array $options = []) 177 | { 178 | $clientOptions = $this->buildClientOptions($options); 179 | $this->setClientOptions($clientOptions); 180 | } 181 | 182 | /** 183 | * Starts asynchronous cancellation on a long-running operation. The server 184 | * makes a best effort to cancel the operation, but success is not 185 | * guaranteed. If the server doesn't support this method, it returns 186 | * `google.rpc.Code.UNIMPLEMENTED`. Clients can use 187 | * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or 188 | * other methods to check whether the cancellation succeeded or whether the 189 | * operation completed despite cancellation. On successful cancellation, 190 | * the operation is not deleted; instead, it becomes an operation with 191 | * an [Operation.error][google.longrunning.Operation.error] value with a 192 | * [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to 193 | * `Code.CANCELLED`. 194 | * 195 | * Sample code: 196 | * ``` 197 | * $operationsClient = new OperationsClient(); 198 | * try { 199 | * $name = 'name'; 200 | * $operationsClient->cancelOperation($name); 201 | * } finally { 202 | * $operationsClient->close(); 203 | * } 204 | * ``` 205 | * 206 | * @param string $name The name of the operation resource to be cancelled. 207 | * @param array $optionalArgs { 208 | * Optional. 209 | * 210 | * @type RetrySettings|array $retrySettings 211 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 212 | * associative array of retry settings parameters. See the documentation on 213 | * {@see RetrySettings} for example usage. 214 | * } 215 | * 216 | * @throws ApiException if the remote call fails 217 | */ 218 | public function cancelOperation($name, array $optionalArgs = []) 219 | { 220 | $request = new CancelOperationRequest(); 221 | $requestParamHeaders = []; 222 | $request->setName($name); 223 | $requestParamHeaders['name'] = $name; 224 | $requestParams = new RequestParamsHeaderDescriptor( 225 | $requestParamHeaders 226 | ); 227 | $optionalArgs['headers'] = isset($optionalArgs['headers']) 228 | ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) 229 | : $requestParams->getHeader(); 230 | return $this->startCall( 231 | 'CancelOperation', 232 | GPBEmpty::class, 233 | $optionalArgs, 234 | $request 235 | )->wait(); 236 | } 237 | 238 | /** 239 | * Deletes a long-running operation. This method indicates that the client is 240 | * no longer interested in the operation result. It does not cancel the 241 | * operation. If the server doesn't support this method, it returns 242 | * `google.rpc.Code.UNIMPLEMENTED`. 243 | * 244 | * Sample code: 245 | * ``` 246 | * $operationsClient = new OperationsClient(); 247 | * try { 248 | * $name = 'name'; 249 | * $operationsClient->deleteOperation($name); 250 | * } finally { 251 | * $operationsClient->close(); 252 | * } 253 | * ``` 254 | * 255 | * @param string $name The name of the operation resource to be deleted. 256 | * @param array $optionalArgs { 257 | * Optional. 258 | * 259 | * @type RetrySettings|array $retrySettings 260 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 261 | * associative array of retry settings parameters. See the documentation on 262 | * {@see RetrySettings} for example usage. 263 | * } 264 | * 265 | * @throws ApiException if the remote call fails 266 | */ 267 | public function deleteOperation($name, array $optionalArgs = []) 268 | { 269 | $request = new DeleteOperationRequest(); 270 | $requestParamHeaders = []; 271 | $request->setName($name); 272 | $requestParamHeaders['name'] = $name; 273 | $requestParams = new RequestParamsHeaderDescriptor( 274 | $requestParamHeaders 275 | ); 276 | $optionalArgs['headers'] = isset($optionalArgs['headers']) 277 | ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) 278 | : $requestParams->getHeader(); 279 | return $this->startCall( 280 | 'DeleteOperation', 281 | GPBEmpty::class, 282 | $optionalArgs, 283 | $request 284 | )->wait(); 285 | } 286 | 287 | /** 288 | * Gets the latest state of a long-running operation. Clients can use this 289 | * method to poll the operation result at intervals as recommended by the API 290 | * service. 291 | * 292 | * Sample code: 293 | * ``` 294 | * $operationsClient = new OperationsClient(); 295 | * try { 296 | * $name = 'name'; 297 | * $response = $operationsClient->getOperation($name); 298 | * } finally { 299 | * $operationsClient->close(); 300 | * } 301 | * ``` 302 | * 303 | * @param string $name The name of the operation resource. 304 | * @param array $optionalArgs { 305 | * Optional. 306 | * 307 | * @type RetrySettings|array $retrySettings 308 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 309 | * associative array of retry settings parameters. See the documentation on 310 | * {@see RetrySettings} for example usage. 311 | * } 312 | * 313 | * @return \Google\LongRunning\Operation 314 | * 315 | * @throws ApiException if the remote call fails 316 | */ 317 | public function getOperation($name, array $optionalArgs = []) 318 | { 319 | $request = new GetOperationRequest(); 320 | $requestParamHeaders = []; 321 | $request->setName($name); 322 | $requestParamHeaders['name'] = $name; 323 | $requestParams = new RequestParamsHeaderDescriptor( 324 | $requestParamHeaders 325 | ); 326 | $optionalArgs['headers'] = isset($optionalArgs['headers']) 327 | ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) 328 | : $requestParams->getHeader(); 329 | return $this->startCall( 330 | 'GetOperation', 331 | Operation::class, 332 | $optionalArgs, 333 | $request 334 | )->wait(); 335 | } 336 | 337 | /** 338 | * Lists operations that match the specified filter in the request. If the 339 | * server doesn't support this method, it returns `UNIMPLEMENTED`. 340 | * 341 | * Sample code: 342 | * ``` 343 | * $operationsClient = new OperationsClient(); 344 | * try { 345 | * $name = 'name'; 346 | * $filter = 'filter'; 347 | * // Iterate over pages of elements 348 | * $pagedResponse = $operationsClient->listOperations($name, $filter); 349 | * foreach ($pagedResponse->iteratePages() as $page) { 350 | * foreach ($page as $element) { 351 | * // doSomethingWith($element); 352 | * } 353 | * } 354 | * // Alternatively: 355 | * // Iterate through all elements 356 | * $pagedResponse = $operationsClient->listOperations($name, $filter); 357 | * foreach ($pagedResponse->iterateAllElements() as $element) { 358 | * // doSomethingWith($element); 359 | * } 360 | * } finally { 361 | * $operationsClient->close(); 362 | * } 363 | * ``` 364 | * 365 | * @param string $name The name of the operation's parent resource. 366 | * @param string $filter The standard list filter. 367 | * @param array $optionalArgs { 368 | * Optional. 369 | * 370 | * @type int $pageSize 371 | * The maximum number of resources contained in the underlying API 372 | * response. The API may return fewer values in a page, even if 373 | * there are additional values to be retrieved. 374 | * @type string $pageToken 375 | * A page token is used to specify a page of values to be returned. 376 | * If no page token is specified (the default), the first page 377 | * of values will be returned. Any page token used here must have 378 | * been generated by a previous call to the API. 379 | * @type bool $returnPartialSuccess 380 | * When set to `true`, operations that are reachable are returned as normal, 381 | * and those that are unreachable are returned in the 382 | * [ListOperationsResponse.unreachable] field. 383 | * 384 | * This can only be `true` when reading across collections e.g. when `parent` 385 | * is set to `"projects/example/locations/-"`. 386 | * 387 | * This field is not by default supported and will result in an 388 | * `UNIMPLEMENTED` error if set unless explicitly documented otherwise in 389 | * service or product specific documentation. 390 | * @type RetrySettings|array $retrySettings 391 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 392 | * associative array of retry settings parameters. See the documentation on 393 | * {@see RetrySettings} for example usage. 394 | * } 395 | * 396 | * @return \Google\ApiCore\PagedListResponse 397 | * 398 | * @throws ApiException if the remote call fails 399 | */ 400 | public function listOperations($name, $filter, array $optionalArgs = []) 401 | { 402 | $request = new ListOperationsRequest(); 403 | $requestParamHeaders = []; 404 | $request->setName($name); 405 | $request->setFilter($filter); 406 | $requestParamHeaders['name'] = $name; 407 | if (isset($optionalArgs['pageSize'])) { 408 | $request->setPageSize($optionalArgs['pageSize']); 409 | } 410 | 411 | if (isset($optionalArgs['pageToken'])) { 412 | $request->setPageToken($optionalArgs['pageToken']); 413 | } 414 | 415 | if (isset($optionalArgs['returnPartialSuccess'])) { 416 | $request->setReturnPartialSuccess( 417 | $optionalArgs['returnPartialSuccess'] 418 | ); 419 | } 420 | 421 | $requestParams = new RequestParamsHeaderDescriptor( 422 | $requestParamHeaders 423 | ); 424 | $optionalArgs['headers'] = isset($optionalArgs['headers']) 425 | ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) 426 | : $requestParams->getHeader(); 427 | return $this->getPagedListResponse( 428 | 'ListOperations', 429 | $optionalArgs, 430 | ListOperationsResponse::class, 431 | $request 432 | ); 433 | } 434 | 435 | /** 436 | * Waits until the specified long-running operation is done or reaches at most 437 | * a specified timeout, returning the latest state. If the operation is 438 | * already done, the latest state is immediately returned. If the timeout 439 | * specified is greater than the default HTTP/RPC timeout, the HTTP/RPC 440 | * timeout is used. If the server does not support this method, it returns 441 | * `google.rpc.Code.UNIMPLEMENTED`. 442 | * Note that this method is on a best-effort basis. It may return the latest 443 | * state before the specified timeout (including immediately), meaning even an 444 | * immediate response is no guarantee that the operation is done. 445 | * 446 | * Sample code: 447 | * ``` 448 | * $operationsClient = new OperationsClient(); 449 | * try { 450 | * $response = $operationsClient->waitOperation(); 451 | * } finally { 452 | * $operationsClient->close(); 453 | * } 454 | * ``` 455 | * 456 | * @param array $optionalArgs { 457 | * Optional. 458 | * 459 | * @type string $name 460 | * The name of the operation resource to wait on. 461 | * @type Duration $timeout 462 | * The maximum duration to wait before timing out. If left blank, the wait 463 | * will be at most the time permitted by the underlying HTTP/RPC protocol. 464 | * If RPC context deadline is also specified, the shorter one will be used. 465 | * @type RetrySettings|array $retrySettings 466 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 467 | * associative array of retry settings parameters. See the documentation on 468 | * {@see RetrySettings} for example usage. 469 | * } 470 | * 471 | * @return \Google\LongRunning\Operation 472 | * 473 | * @throws ApiException if the remote call fails 474 | */ 475 | public function waitOperation(array $optionalArgs = []) 476 | { 477 | $request = new WaitOperationRequest(); 478 | if (isset($optionalArgs['name'])) { 479 | $request->setName($optionalArgs['name']); 480 | } 481 | 482 | if (isset($optionalArgs['timeout'])) { 483 | $request->setTimeout($optionalArgs['timeout']); 484 | } 485 | 486 | return $this->startCall( 487 | 'WaitOperation', 488 | Operation::class, 489 | $optionalArgs, 490 | $request 491 | )->wait(); 492 | } 493 | } 494 | --------------------------------------------------------------------------------