PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/google/google/longrunning/src/LongRunning/Client/OperationsClient.php +65 -56 1.2.01.4.1 View file →
@@ -20,44 +20,46 @@
20 20 * Generated by gapic-generator-php from the file
21 21 * https://github.com/googleapis/googleapis/blob/master/google/longrunning/operations.proto
22 22 * Updates to the above are reflected here through a refresh process.
23 23 */
24 -namespace Dudlewebs\WPMCS\Google\LongRunning\Client;
24 +namespace Dudlewebs\WPMCS\GCP\Google\LongRunning\Client;
25 25
26 -use Dudlewebs\WPMCS\Google\ApiCore\ApiException;
27 -use Dudlewebs\WPMCS\Google\ApiCore\CredentialsWrapper;
28 -use Dudlewebs\WPMCS\Google\ApiCore\GapicClientTrait;
29 -use Dudlewebs\WPMCS\Google\ApiCore\PagedListResponse;
30 -use Dudlewebs\WPMCS\Google\ApiCore\RetrySettings;
31 -use Dudlewebs\WPMCS\Google\ApiCore\Transport\TransportInterface;
32 -use Dudlewebs\WPMCS\Google\ApiCore\ValidationException;
33 -use Dudlewebs\WPMCS\Google\Auth\FetchAuthTokenInterface;
34 -use Dudlewebs\WPMCS\Google\LongRunning\CancelOperationRequest;
35 -use Dudlewebs\WPMCS\Google\LongRunning\DeleteOperationRequest;
36 -use Dudlewebs\WPMCS\Google\LongRunning\GetOperationRequest;
37 -use Dudlewebs\WPMCS\Google\LongRunning\ListOperationsRequest;
38 -use Dudlewebs\WPMCS\Google\LongRunning\Operation;
39 -use Dudlewebs\WPMCS\Google\LongRunning\WaitOperationRequest;
40 -use Dudlewebs\WPMCS\GuzzleHttp\Promise\PromiseInterface;
26 +use Dudlewebs\WPMCS\GCP\Google\ApiCore\ApiException;
27 +use Dudlewebs\WPMCS\GCP\Google\ApiCore\CredentialsWrapper;
28 +use Dudlewebs\WPMCS\GCP\Google\ApiCore\GapicClientTrait;
29 +use Dudlewebs\WPMCS\GCP\Google\ApiCore\Options\ClientOptions;
30 +use Dudlewebs\WPMCS\GCP\Google\ApiCore\PagedListResponse;
31 +use Dudlewebs\WPMCS\GCP\Google\ApiCore\RetrySettings;
32 +use Dudlewebs\WPMCS\GCP\Google\ApiCore\Transport\TransportInterface;
33 +use Dudlewebs\WPMCS\GCP\Google\ApiCore\ValidationException;
34 +use Dudlewebs\WPMCS\GCP\Google\Auth\FetchAuthTokenInterface;
35 +use Dudlewebs\WPMCS\GCP\Google\LongRunning\CancelOperationRequest;
36 +use Dudlewebs\WPMCS\GCP\Google\LongRunning\DeleteOperationRequest;
37 +use Dudlewebs\WPMCS\GCP\Google\LongRunning\GetOperationRequest;
38 +use Dudlewebs\WPMCS\GCP\Google\LongRunning\ListOperationsRequest;
39 +use Dudlewebs\WPMCS\GCP\Google\LongRunning\Operation;
40 +use Dudlewebs\WPMCS\GCP\Google\LongRunning\WaitOperationRequest;
41 +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise\PromiseInterface;
42 +use Dudlewebs\WPMCS\GCP\Psr\Log\LoggerInterface;
41 43 /**
42 44 * Service Description: Manages long-running operations with an API service.
43 45 *
44 46 * When an API method normally takes long time to complete, it can be designed
45 - * to return [Operation][google.longrunning.Operation] to the client, and the client can use this
46 - * interface to receive the real response asynchronously by polling the
47 - * operation resource, or pass the operation resource to another API (such as
48 - * Google Cloud Pub/Sub API) to receive the response. Any API service that
49 - * returns long-running operations should implement the `Operations` interface
50 - * so developers can have a consistent client experience.
47 + * to return [Operation][google.longrunning.Operation] to the client, and the
48 + * client can use this interface to receive the real response asynchronously by
49 + * polling the operation resource, or pass the operation resource to another API
50 + * (such as Pub/Sub API) to receive the response. Any API service that returns
51 + * long-running operations should implement the `Operations` interface so
52 + * developers can have a consistent client experience.
51 53 *
52 54 * This class provides the ability to make remote calls to the backing service through method
53 55 * calls that map to API methods.
54 56 *
55 - * @method PromiseInterface cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = [])
56 - * @method PromiseInterface deleteOperationAsync(DeleteOperationRequest $request, array $optionalArgs = [])
57 - * @method PromiseInterface getOperationAsync(GetOperationRequest $request, array $optionalArgs = [])
58 - * @method PromiseInterface listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = [])
59 - * @method PromiseInterface waitOperationAsync(WaitOperationRequest $request, array $optionalArgs = [])
57 + * @method PromiseInterface<void> cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = [])
58 + * @method PromiseInterface<void> deleteOperationAsync(DeleteOperationRequest $request, array $optionalArgs = [])
59 + * @method PromiseInterface<Operation> getOperationAsync(GetOperationRequest $request, array $optionalArgs = [])
60 + * @method PromiseInterface<PagedListResponse> listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = [])
61 + * @method PromiseInterface<Operation> waitOperationAsync(WaitOperationRequest $request, array $optionalArgs = [])
60 62 */
61 63 class OperationsClient
62 64 {
63 65 use GapicClientTrait;
@@ -83,22 +85,31 @@
83 85 }
84 86 /**
85 87 * Constructor.
86 88 *
87 - * @param array $options {
89 + * @param array|ClientOptions $options {
88 90 * Optional. Options for configuring the service API wrapper.
89 91 *
90 92 * @type string $apiEndpoint
91 93 * The address of the API remote host. May optionally include the port, formatted
92 94 * as "<uri>:<port>". Default 'longrunning.googleapis.com:443'.
93 - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
94 - * The credentials to be used by the client to authorize API calls. This option
95 - * accepts either a path to a credentials file, or a decoded credentials file as a
96 - * PHP array.
97 - * *Advanced usage*: In addition, this option can also accept a pre-constructed
98 - * {@see \Google\Auth\FetchAuthTokenInterface} object or
99 - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
100 - * objects are provided, any settings in $credentialsConfig will be ignored.
95 + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials
96 + * This option should only be used with a pre-constructed
97 + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that
98 + * when one of these objects are provided, any settings in $credentialsConfig will
99 + * be ignored.
100 + * **Important**: If you are providing a path to a credentials file, or a decoded
101 + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an
102 + * unvalidated credential configuration to Google APIs can compromise the security
103 + * of your systems and data. It is recommended to create the credentials explicitly
104 + * ```
105 + * use Google\Auth\Credentials\ServiceAccountCredentials;
106 + * use Google\LongRunning\OperationsClient;
107 + * $creds = new ServiceAccountCredentials($scopes, $json);
108 + * $options = new OperationsClient(['credentials' => $creds]);
109 + * ```
110 + * {@see
111 + * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials}
101 112 * @type array $credentialsConfig
102 113 * Options used to configure credentials, including auth token caching, for the
103 114 * client. For a full list of supporting configuration options, see
104 115 * {@see \Google\ApiCore\CredentialsWrapper::build()} .
@@ -130,13 +141,18 @@
130 141 * supported options.
131 142 * @type callable $clientCertSource
132 143 * A callable which returns the client cert as a string. This can be used to
133 144 * provide a certificate and private key to the transport layer for mTLS.
145 + * @type false|LoggerInterface $logger
146 + * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
147 + * 'GOOGLE_SDK_PHP_LOGGING' environment flag
148 + * @type string $universeDomain
149 + * The service domain for the client. Defaults to 'googleapis.com'.
134 150 * }
135 151 *
136 152 * @throws ValidationException
137 153 */
138 - public function __construct(array $options = [])
154 + public function __construct(array|ClientOptions $options = [])
139 155 {
140 156 $clientOptions = $this->buildClientOptions($options);
141 157 $this->setClientOptions($clientOptions);
142 158 }
@@ -142,13 +158,13 @@
142 158 }
143 159 /** Handles execution of the async variants for each documented method. */
144 160 public function __call($method, $args)
145 161 {
146 - if (substr($method, -5) !== 'Async') {
147 - trigger_error('Call to undefined method ' . __CLASS__ . "::{$method}()", \E_USER_ERROR);
162 + if (\substr($method, -5) !== 'Async') {
163 + \trigger_error('Call to undefined method ' . __CLASS__ . "::{$method}()", \E_USER_ERROR);
148 164 }
149 - array_unshift($args, substr($method, 0, -5));
150 - return call_user_func_array([$this, 'startAsyncCall'], $args);
165 + \array_unshift($args, \substr($method, 0, -5));
166 + return \call_user_func_array([$this, 'startAsyncCall'], $args);
151 167 }
152 168 /**
153 169 * Starts asynchronous cancellation on a long-running operation. The server
154 170 * makes a best effort to cancel the operation, but success is not
@@ -157,10 +173,11 @@
157 173 * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
158 174 * other methods to check whether the cancellation succeeded or whether the
159 175 * operation completed despite cancellation. On successful cancellation,
160 176 * the operation is not deleted; instead, it becomes an operation with
161 - * an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
162 - * corresponding to `Code.CANCELLED`.
177 + * an [Operation.error][google.longrunning.Operation.error] value with a
178 + * [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to
179 + * `Code.CANCELLED`.
163 180 *
164 181 * The async variant is {@see OperationsClient::cancelOperationAsync()} .
165 182 *
166 183 * @example samples/OperationsClient/cancel_operation.php
@@ -176,9 +193,9 @@
176 193 * }
177 194 *
178 195 * @throws ApiException Thrown if the API call fails.
179 196 */
180 - public function cancelOperation(CancelOperationRequest $request, array $callOptions = []): void
197 + public function cancelOperation(CancelOperationRequest $request, array $callOptions = []) : void
181 198 {
182 199 $this->startApiCall('CancelOperation', $request, $callOptions)->wait();
183 200 }
184 201 /**
@@ -202,9 +219,9 @@
202 219 * }
203 220 *
204 221 * @throws ApiException Thrown if the API call fails.
205 222 */
206 - public function deleteOperation(DeleteOperationRequest $request, array $callOptions = []): void
223 + public function deleteOperation(DeleteOperationRequest $request, array $callOptions = []) : void
207 224 {
208 225 $this->startApiCall('DeleteOperation', $request, $callOptions)->wait();
209 226 }
210 227 /**
@@ -229,9 +246,9 @@
229 246 * @return Operation
230 247 *
231 248 * @throws ApiException Thrown if the API call fails.
232 249 */
233 - public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation
250 + public function getOperation(GetOperationRequest $request, array $callOptions = []) : Operation
234 251 {
235 252 return $this->startApiCall('GetOperation', $request, $callOptions)->wait();
236 253 }
237 254 /**
@@ -237,16 +254,8 @@
237 254 /**
238 255 * Lists operations that match the specified filter in the request. If the
239 256 * server doesn't support this method, it returns `UNIMPLEMENTED`.
240 257 *
241 - * NOTE: the `name` binding allows API services to override the binding
242 - * to use different resource name schemes, such as `users/&#42;/operations`. To
243 - * override the binding, API services can add a binding such as
244 - * `"/v1/{name=users/*}/operations"` to their service configuration.
245 - * For backwards compatibility, the default name includes the operations
246 - * collection id, however overriding users must ensure the name binding
247 - * is the parent resource, without the operations collection id.
248 - *
249 258 * The async variant is {@see OperationsClient::listOperationsAsync()} .
250 259 *
251 260 * @example samples/OperationsClient/list_operations.php
252 261 *
@@ -263,9 +272,9 @@
263 272 * @return PagedListResponse
264 273 *
265 274 * @throws ApiException Thrown if the API call fails.
266 275 */
267 - public function listOperations(ListOperationsRequest $request, array $callOptions = []): PagedListResponse
276 + public function listOperations(ListOperationsRequest $request, array $callOptions = []) : PagedListResponse
268 277 {
269 278 return $this->startApiCall('ListOperations', $request, $callOptions);
270 279 }
271 280 /**
@@ -296,9 +305,9 @@
296 305 * @return Operation
297 306 *
298 307 * @throws ApiException Thrown if the API call fails.
299 308 */
300 - public function waitOperation(WaitOperationRequest $request, array $callOptions = []): Operation
309 + public function waitOperation(WaitOperationRequest $request, array $callOptions = []) : Operation
301 310 {
302 311 return $this->startApiCall('WaitOperation', $request, $callOptions)->wait();
303 312 }
304 313 }