├── .gitattributes ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── VERSION ├── composer.json ├── metadata ├── Longrunning │ └── Operations.php └── README.md └── src ├── ApiCore └── LongRunning │ ├── Gapic │ └── OperationsGapicClient.php │ └── OperationsClient.php └── LongRunning ├── CancelOperationRequest.php ├── Client └── OperationsClient.php ├── DeleteOperationRequest.php ├── Gapic └── OperationsGapicClient.php ├── GetOperationRequest.php ├── ListOperationsRequest.php ├── ListOperationsResponse.php ├── Operation.php ├── OperationInfo.php ├── OperationsClient.php ├── OperationsGrpcClient.php ├── WaitOperationRequest.php └── resources ├── operations_client_config.json ├── operations_descriptor_config.php └── operations_rest_client_config.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 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, 4 | and in the interest of fostering an open and welcoming community, 5 | we pledge to respect all people who contribute through reporting issues, 6 | posting feature requests, updating documentation, 7 | submitting pull requests or patches, and other activities. 8 | 9 | We are committed to making participation in this project 10 | a harassment-free experience for everyone, 11 | regardless of level of experience, gender, gender identity and expression, 12 | sexual orientation, disability, personal appearance, 13 | body size, race, ethnicity, age, religion, or nationality. 14 | 15 | Examples of unacceptable behavior by participants include: 16 | 17 | * The use of sexualized language or imagery 18 | * Personal attacks 19 | * Trolling or insulting/derogatory comments 20 | * Public or private harassment 21 | * Publishing other's private information, 22 | such as physical or electronic 23 | addresses, without explicit permission 24 | * Other unethical or unprofessional conduct. 25 | 26 | Project maintainers have the right and responsibility to remove, edit, or reject 27 | comments, commits, code, wiki edits, issues, and other contributions 28 | that are not aligned to this Code of Conduct. 29 | By adopting this Code of Conduct, 30 | project maintainers commit themselves to fairly and consistently 31 | applying these principles to every aspect of managing this project. 32 | Project maintainers who do not follow or enforce the Code of Conduct 33 | may be permanently removed from the project team. 34 | 35 | This code of conduct applies both within project spaces and in public spaces 36 | when an individual is representing the project or its community. 37 | 38 | Instances of abusive, harassing, or otherwise unacceptable behavior 39 | may be reported by opening an issue 40 | or contacting one or more of the project maintainers. 41 | 42 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, 43 | available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. We accept 4 | and review pull requests against the main 5 | [Google Cloud PHP](https://github.com/googleapis/google-cloud-php) 6 | repository, which contains all of our client libraries. You will also need to 7 | sign a Contributor License Agreement. For more details about how to contribute, 8 | see the 9 | [CONTRIBUTING.md](https://github.com/googleapis/google-cloud-php/blob/main/CONTRIBUTING.md) 10 | file in the main Google Cloud PHP repository. 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google LongRunning API for PHP 2 | 3 | > 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.4.7 2 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "google/longrunning", 3 | "description": "Google LongRunning Client for PHP", 4 | "license": "Apache-2.0", 5 | "minimum-stability": "stable", 6 | "version": "0.4.7", 7 | "autoload": { 8 | "psr-4": { 9 | "Google\\ApiCore\\LongRunning\\": "src/ApiCore/LongRunning", 10 | "Google\\LongRunning\\": "src/LongRunning", 11 | "GPBMetadata\\Google\\Longrunning\\": "metadata/Longrunning" 12 | } 13 | }, 14 | "extra": { 15 | "component": { 16 | "id": "longrunning", 17 | "path": "LongRunning", 18 | "entry": null, 19 | "target": "googleapis/php-longrunning" 20 | } 21 | }, 22 | "require-dev": { 23 | "google/gax": "^1.36.0", 24 | "phpunit/phpunit": "^9.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /metadata/Longrunning/Operations.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/php-longrunning/624cabb874c10e5ddc9034c999f724894b70a3d3/metadata/Longrunning/Operations.php -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/ApiCore/LongRunning/Gapic/OperationsGapicClient.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/Client/OperationsClient.php: -------------------------------------------------------------------------------- 1 | cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = []) 59 | * @method PromiseInterface deleteOperationAsync(DeleteOperationRequest $request, array $optionalArgs = []) 60 | * @method PromiseInterface getOperationAsync(GetOperationRequest $request, array $optionalArgs = []) 61 | * @method PromiseInterface listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = []) 62 | * @method PromiseInterface waitOperationAsync(WaitOperationRequest $request, array $optionalArgs = []) 63 | */ 64 | class OperationsClient 65 | { 66 | use GapicClientTrait; 67 | 68 | /** The name of the service. */ 69 | private const SERVICE_NAME = 'google.longrunning.Operations'; 70 | 71 | /** 72 | * The default address of the service. 73 | * 74 | * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. 75 | */ 76 | private const SERVICE_ADDRESS = 'longrunning.googleapis.com'; 77 | 78 | /** The address template of the service. */ 79 | private const SERVICE_ADDRESS_TEMPLATE = 'longrunning.UNIVERSE_DOMAIN'; 80 | 81 | /** The default port of the service. */ 82 | private const DEFAULT_SERVICE_PORT = 443; 83 | 84 | /** The name of the code generator, to be included in the agent header. */ 85 | private const CODEGEN_NAME = 'gapic'; 86 | 87 | /** The default scopes required by the service. */ 88 | public static $serviceScopes = []; 89 | 90 | private static function getClientDefaults() 91 | { 92 | return [ 93 | 'serviceName' => self::SERVICE_NAME, 94 | 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, 95 | 'clientConfig' => __DIR__ . '/../resources/operations_client_config.json', 96 | 'descriptorsConfigPath' => __DIR__ . '/../resources/operations_descriptor_config.php', 97 | 'gcpApiConfigPath' => __DIR__ . '/../resources/operations_grpc_config.json', 98 | 'credentialsConfig' => [ 99 | 'defaultScopes' => self::$serviceScopes, 100 | ], 101 | 'transportConfig' => [ 102 | 'rest' => [ 103 | 'restClientConfigPath' => __DIR__ . '/../resources/operations_rest_client_config.php', 104 | ], 105 | ], 106 | ]; 107 | } 108 | 109 | /** 110 | * Constructor. 111 | * 112 | * @param array $options { 113 | * Optional. Options for configuring the service API wrapper. 114 | * 115 | * @type string $apiEndpoint 116 | * The address of the API remote host. May optionally include the port, formatted 117 | * as ":". Default 'longrunning.googleapis.com:443'. 118 | * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials 119 | * The credentials to be used by the client to authorize API calls. This option 120 | * accepts either a path to a credentials file, or a decoded credentials file as a 121 | * PHP array. 122 | * *Advanced usage*: In addition, this option can also accept a pre-constructed 123 | * {@see \Google\Auth\FetchAuthTokenInterface} object or 124 | * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these 125 | * objects are provided, any settings in $credentialsConfig will be ignored. 126 | * *Important*: If you accept a credential configuration (credential 127 | * JSON/File/Stream) from an external source for authentication to Google Cloud 128 | * Platform, you must validate it before providing it to any Google API or library. 129 | * Providing an unvalidated credential configuration to Google APIs can compromise 130 | * the security of your systems and data. For more information {@see 131 | * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} 132 | * @type array $credentialsConfig 133 | * Options used to configure credentials, including auth token caching, for the 134 | * client. For a full list of supporting configuration options, see 135 | * {@see \Google\ApiCore\CredentialsWrapper::build()} . 136 | * @type bool $disableRetries 137 | * Determines whether or not retries defined by the client configuration should be 138 | * disabled. Defaults to `false`. 139 | * @type string|array $clientConfig 140 | * Client method configuration, including retry settings. This option can be either 141 | * a path to a JSON file, or a PHP array containing the decoded JSON data. By 142 | * default this settings points to the default client config file, which is 143 | * provided in the resources folder. 144 | * @type string|TransportInterface $transport 145 | * The transport used for executing network requests. May be either the string 146 | * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. 147 | * *Advanced usage*: Additionally, it is possible to pass in an already 148 | * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note 149 | * that when this object is provided, any settings in $transportConfig, and any 150 | * $apiEndpoint setting, will be ignored. 151 | * @type array $transportConfig 152 | * Configuration options that will be used to construct the transport. Options for 153 | * each supported transport type should be passed in a key for that transport. For 154 | * example: 155 | * $transportConfig = [ 156 | * 'grpc' => [...], 157 | * 'rest' => [...], 158 | * ]; 159 | * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and 160 | * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the 161 | * supported options. 162 | * @type callable $clientCertSource 163 | * A callable which returns the client cert as a string. This can be used to 164 | * provide a certificate and private key to the transport layer for mTLS. 165 | * @type false|LoggerInterface $logger 166 | * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 167 | * 'GOOGLE_SDK_PHP_LOGGING' environment flag 168 | * } 169 | * 170 | * @throws ValidationException 171 | */ 172 | public function __construct(array $options = []) 173 | { 174 | $clientOptions = $this->buildClientOptions($options); 175 | $this->setClientOptions($clientOptions); 176 | } 177 | 178 | /** Handles execution of the async variants for each documented method. */ 179 | public function __call($method, $args) 180 | { 181 | if (substr($method, -5) !== 'Async') { 182 | trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); 183 | } 184 | 185 | array_unshift($args, substr($method, 0, -5)); 186 | return call_user_func_array([$this, 'startAsyncCall'], $args); 187 | } 188 | 189 | /** 190 | * Starts asynchronous cancellation on a long-running operation. The server 191 | * makes a best effort to cancel the operation, but success is not 192 | * guaranteed. If the server doesn't support this method, it returns 193 | * `google.rpc.Code.UNIMPLEMENTED`. Clients can use 194 | * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or 195 | * other methods to check whether the cancellation succeeded or whether the 196 | * operation completed despite cancellation. On successful cancellation, 197 | * the operation is not deleted; instead, it becomes an operation with 198 | * an [Operation.error][google.longrunning.Operation.error] value with a 199 | * [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to 200 | * `Code.CANCELLED`. 201 | * 202 | * The async variant is {@see OperationsClient::cancelOperationAsync()} . 203 | * 204 | * @example samples/OperationsClient/cancel_operation.php 205 | * 206 | * @param CancelOperationRequest $request A request to house fields associated with the call. 207 | * @param array $callOptions { 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 Thrown if the API call fails. 217 | */ 218 | public function cancelOperation(CancelOperationRequest $request, array $callOptions = []): void 219 | { 220 | $this->startApiCall('CancelOperation', $request, $callOptions)->wait(); 221 | } 222 | 223 | /** 224 | * Deletes a long-running operation. This method indicates that the client is 225 | * no longer interested in the operation result. It does not cancel the 226 | * operation. If the server doesn't support this method, it returns 227 | * `google.rpc.Code.UNIMPLEMENTED`. 228 | * 229 | * The async variant is {@see OperationsClient::deleteOperationAsync()} . 230 | * 231 | * @example samples/OperationsClient/delete_operation.php 232 | * 233 | * @param DeleteOperationRequest $request A request to house fields associated with the call. 234 | * @param array $callOptions { 235 | * Optional. 236 | * 237 | * @type RetrySettings|array $retrySettings 238 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 239 | * associative array of retry settings parameters. See the documentation on 240 | * {@see RetrySettings} for example usage. 241 | * } 242 | * 243 | * @throws ApiException Thrown if the API call fails. 244 | */ 245 | public function deleteOperation(DeleteOperationRequest $request, array $callOptions = []): void 246 | { 247 | $this->startApiCall('DeleteOperation', $request, $callOptions)->wait(); 248 | } 249 | 250 | /** 251 | * Gets the latest state of a long-running operation. Clients can use this 252 | * method to poll the operation result at intervals as recommended by the API 253 | * service. 254 | * 255 | * The async variant is {@see OperationsClient::getOperationAsync()} . 256 | * 257 | * @example samples/OperationsClient/get_operation.php 258 | * 259 | * @param GetOperationRequest $request A request to house fields associated with the call. 260 | * @param array $callOptions { 261 | * Optional. 262 | * 263 | * @type RetrySettings|array $retrySettings 264 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 265 | * associative array of retry settings parameters. See the documentation on 266 | * {@see RetrySettings} for example usage. 267 | * } 268 | * 269 | * @return Operation 270 | * 271 | * @throws ApiException Thrown if the API call fails. 272 | */ 273 | public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation 274 | { 275 | return $this->startApiCall('GetOperation', $request, $callOptions)->wait(); 276 | } 277 | 278 | /** 279 | * Lists operations that match the specified filter in the request. If the 280 | * server doesn't support this method, it returns `UNIMPLEMENTED`. 281 | * 282 | * The async variant is {@see OperationsClient::listOperationsAsync()} . 283 | * 284 | * @example samples/OperationsClient/list_operations.php 285 | * 286 | * @param ListOperationsRequest $request A request to house fields associated with the call. 287 | * @param array $callOptions { 288 | * Optional. 289 | * 290 | * @type RetrySettings|array $retrySettings 291 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 292 | * associative array of retry settings parameters. See the documentation on 293 | * {@see RetrySettings} for example usage. 294 | * } 295 | * 296 | * @return PagedListResponse 297 | * 298 | * @throws ApiException Thrown if the API call fails. 299 | */ 300 | public function listOperations(ListOperationsRequest $request, array $callOptions = []): PagedListResponse 301 | { 302 | return $this->startApiCall('ListOperations', $request, $callOptions); 303 | } 304 | 305 | /** 306 | * Waits until the specified long-running operation is done or reaches at most 307 | * a specified timeout, returning the latest state. If the operation is 308 | * already done, the latest state is immediately returned. If the timeout 309 | * specified is greater than the default HTTP/RPC timeout, the HTTP/RPC 310 | * timeout is used. If the server does not support this method, it returns 311 | * `google.rpc.Code.UNIMPLEMENTED`. 312 | * Note that this method is on a best-effort basis. It may return the latest 313 | * state before the specified timeout (including immediately), meaning even an 314 | * immediate response is no guarantee that the operation is done. 315 | * 316 | * The async variant is {@see OperationsClient::waitOperationAsync()} . 317 | * 318 | * @example samples/OperationsClient/wait_operation.php 319 | * 320 | * @param WaitOperationRequest $request A request to house fields associated with the call. 321 | * @param array $callOptions { 322 | * Optional. 323 | * 324 | * @type RetrySettings|array $retrySettings 325 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 326 | * associative array of retry settings parameters. See the documentation on 327 | * {@see RetrySettings} for example usage. 328 | * } 329 | * 330 | * @return Operation 331 | * 332 | * @throws ApiException Thrown if the API call fails. 333 | */ 334 | public function waitOperation(WaitOperationRequest $request, array $callOptions = []): Operation 335 | { 336 | return $this->startApiCall('WaitOperation', $request, $callOptions)->wait(); 337 | } 338 | } 339 | -------------------------------------------------------------------------------- /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/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 RetrySettings|array $retrySettings 380 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 381 | * associative array of retry settings parameters. See the documentation on 382 | * {@see RetrySettings} for example usage. 383 | * } 384 | * 385 | * @return \Google\ApiCore\PagedListResponse 386 | * 387 | * @throws ApiException if the remote call fails 388 | */ 389 | public function listOperations($name, $filter, array $optionalArgs = []) 390 | { 391 | $request = new ListOperationsRequest(); 392 | $requestParamHeaders = []; 393 | $request->setName($name); 394 | $request->setFilter($filter); 395 | $requestParamHeaders['name'] = $name; 396 | if (isset($optionalArgs['pageSize'])) { 397 | $request->setPageSize($optionalArgs['pageSize']); 398 | } 399 | 400 | if (isset($optionalArgs['pageToken'])) { 401 | $request->setPageToken($optionalArgs['pageToken']); 402 | } 403 | 404 | $requestParams = new RequestParamsHeaderDescriptor( 405 | $requestParamHeaders 406 | ); 407 | $optionalArgs['headers'] = isset($optionalArgs['headers']) 408 | ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) 409 | : $requestParams->getHeader(); 410 | return $this->getPagedListResponse( 411 | 'ListOperations', 412 | $optionalArgs, 413 | ListOperationsResponse::class, 414 | $request 415 | ); 416 | } 417 | 418 | /** 419 | * Waits until the specified long-running operation is done or reaches at most 420 | * a specified timeout, returning the latest state. If the operation is 421 | * already done, the latest state is immediately returned. If the timeout 422 | * specified is greater than the default HTTP/RPC timeout, the HTTP/RPC 423 | * timeout is used. If the server does not support this method, it returns 424 | * `google.rpc.Code.UNIMPLEMENTED`. 425 | * Note that this method is on a best-effort basis. It may return the latest 426 | * state before the specified timeout (including immediately), meaning even an 427 | * immediate response is no guarantee that the operation is done. 428 | * 429 | * Sample code: 430 | * ``` 431 | * $operationsClient = new OperationsClient(); 432 | * try { 433 | * $response = $operationsClient->waitOperation(); 434 | * } finally { 435 | * $operationsClient->close(); 436 | * } 437 | * ``` 438 | * 439 | * @param array $optionalArgs { 440 | * Optional. 441 | * 442 | * @type string $name 443 | * The name of the operation resource to wait on. 444 | * @type Duration $timeout 445 | * The maximum duration to wait before timing out. If left blank, the wait 446 | * will be at most the time permitted by the underlying HTTP/RPC protocol. 447 | * If RPC context deadline is also specified, the shorter one will be used. 448 | * @type RetrySettings|array $retrySettings 449 | * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an 450 | * associative array of retry settings parameters. See the documentation on 451 | * {@see RetrySettings} for example usage. 452 | * } 453 | * 454 | * @return \Google\LongRunning\Operation 455 | * 456 | * @throws ApiException if the remote call fails 457 | */ 458 | public function waitOperation(array $optionalArgs = []) 459 | { 460 | $request = new WaitOperationRequest(); 461 | if (isset($optionalArgs['name'])) { 462 | $request->setName($optionalArgs['name']); 463 | } 464 | 465 | if (isset($optionalArgs['timeout'])) { 466 | $request->setTimeout($optionalArgs['timeout']); 467 | } 468 | 469 | return $this->startCall( 470 | 'WaitOperation', 471 | Operation::class, 472 | $optionalArgs, 473 | $request 474 | )->wait(); 475 | } 476 | } 477 | -------------------------------------------------------------------------------- /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/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 | /** 45 | * @param string $name The name of the operation's parent resource. 46 | * @param string $filter The standard list filter. 47 | * 48 | * @return \Google\LongRunning\ListOperationsRequest 49 | * 50 | * @experimental 51 | */ 52 | public static function build(string $name, string $filter): self 53 | { 54 | return (new self()) 55 | ->setName($name) 56 | ->setFilter($filter); 57 | } 58 | 59 | /** 60 | * Constructor. 61 | * 62 | * @param array $data { 63 | * Optional. Data for populating the Message object. 64 | * 65 | * @type string $name 66 | * The name of the operation's parent resource. 67 | * @type string $filter 68 | * The standard list filter. 69 | * @type int $page_size 70 | * The standard list page size. 71 | * @type string $page_token 72 | * The standard list page token. 73 | * } 74 | */ 75 | public function __construct($data = NULL) { 76 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 77 | parent::__construct($data); 78 | } 79 | 80 | /** 81 | * The name of the operation's parent resource. 82 | * 83 | * Generated from protobuf field string name = 4; 84 | * @return string 85 | */ 86 | public function getName() 87 | { 88 | return $this->name; 89 | } 90 | 91 | /** 92 | * The name of the operation's parent resource. 93 | * 94 | * Generated from protobuf field string name = 4; 95 | * @param string $var 96 | * @return $this 97 | */ 98 | public function setName($var) 99 | { 100 | GPBUtil::checkString($var, True); 101 | $this->name = $var; 102 | 103 | return $this; 104 | } 105 | 106 | /** 107 | * The standard list filter. 108 | * 109 | * Generated from protobuf field string filter = 1; 110 | * @return string 111 | */ 112 | public function getFilter() 113 | { 114 | return $this->filter; 115 | } 116 | 117 | /** 118 | * The standard list filter. 119 | * 120 | * Generated from protobuf field string filter = 1; 121 | * @param string $var 122 | * @return $this 123 | */ 124 | public function setFilter($var) 125 | { 126 | GPBUtil::checkString($var, True); 127 | $this->filter = $var; 128 | 129 | return $this; 130 | } 131 | 132 | /** 133 | * The standard list page size. 134 | * 135 | * Generated from protobuf field int32 page_size = 2; 136 | * @return int 137 | */ 138 | public function getPageSize() 139 | { 140 | return $this->page_size; 141 | } 142 | 143 | /** 144 | * The standard list page size. 145 | * 146 | * Generated from protobuf field int32 page_size = 2; 147 | * @param int $var 148 | * @return $this 149 | */ 150 | public function setPageSize($var) 151 | { 152 | GPBUtil::checkInt32($var); 153 | $this->page_size = $var; 154 | 155 | return $this; 156 | } 157 | 158 | /** 159 | * The standard list page token. 160 | * 161 | * Generated from protobuf field string page_token = 3; 162 | * @return string 163 | */ 164 | public function getPageToken() 165 | { 166 | return $this->page_token; 167 | } 168 | 169 | /** 170 | * The standard list page token. 171 | * 172 | * Generated from protobuf field string page_token = 3; 173 | * @param string $var 174 | * @return $this 175 | */ 176 | public function setPageToken($var) 177 | { 178 | GPBUtil::checkString($var, True); 179 | $this->page_token = $var; 180 | 181 | return $this; 182 | } 183 | 184 | } 185 | 186 | -------------------------------------------------------------------------------- /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 | /** 33 | * Constructor. 34 | * 35 | * @param array $data { 36 | * Optional. Data for populating the Message object. 37 | * 38 | * @type array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $operations 39 | * A list of operations that matches the specified filter in the request. 40 | * @type string $next_page_token 41 | * The standard List next-page token. 42 | * } 43 | */ 44 | public function __construct($data = NULL) { 45 | \GPBMetadata\Google\Longrunning\Operations::initOnce(); 46 | parent::__construct($data); 47 | } 48 | 49 | /** 50 | * A list of operations that matches the specified filter in the request. 51 | * 52 | * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; 53 | * @return \Google\Protobuf\Internal\RepeatedField 54 | */ 55 | public function getOperations() 56 | { 57 | return $this->operations; 58 | } 59 | 60 | /** 61 | * A list of operations that matches the specified filter in the request. 62 | * 63 | * Generated from protobuf field repeated .google.longrunning.Operation operations = 1; 64 | * @param array<\Google\LongRunning\Operation>|\Google\Protobuf\Internal\RepeatedField $var 65 | * @return $this 66 | */ 67 | public function setOperations($var) 68 | { 69 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\LongRunning\Operation::class); 70 | $this->operations = $arr; 71 | 72 | return $this; 73 | } 74 | 75 | /** 76 | * The standard List next-page token. 77 | * 78 | * Generated from protobuf field string next_page_token = 2; 79 | * @return string 80 | */ 81 | public function getNextPageToken() 82 | { 83 | return $this->next_page_token; 84 | } 85 | 86 | /** 87 | * The standard List next-page token. 88 | * 89 | * Generated from protobuf field string next_page_token = 2; 90 | * @param string $var 91 | * @return $this 92 | */ 93 | public function setNextPageToken($var) 94 | { 95 | GPBUtil::checkString($var, True); 96 | $this->next_page_token = $var; 97 | 98 | return $this; 99 | } 100 | 101 | } 102 | 103 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/OperationsClient.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/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/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_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/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 | --------------------------------------------------------------------------------