|
28 | 28 | use Google\ApiCore\CredentialsWrapper; |
29 | 29 | use Google\ApiCore\GapicClientTrait; |
30 | 30 | use Google\ApiCore\OperationResponse; |
| 31 | +use Google\ApiCore\Options\ClientOptions; |
31 | 32 | use Google\ApiCore\PagedListResponse; |
32 | 33 | use Google\ApiCore\RetrySettings; |
33 | 34 | use Google\ApiCore\Transport\TransportInterface; |
|
40 | 41 | use Google\Cloud\Compute\V1\InsertAddressRequest; |
41 | 42 | use Google\Cloud\Compute\V1\ListAddressesRequest; |
42 | 43 | use Google\Cloud\Compute\V1\MoveAddressRequest; |
43 | | -use Google\Cloud\Compute\V1\RegionOperationsClient; |
44 | 44 | use Google\Cloud\Compute\V1\SetLabelsAddressRequest; |
45 | 45 | use Google\Cloud\Compute\V1\TestIamPermissionsAddressRequest; |
46 | 46 | use Google\Cloud\Compute\V1\TestPermissionsResponse; |
@@ -109,7 +109,6 @@ private static function getClientDefaults() |
109 | 109 | 'restClientConfigPath' => __DIR__ . '/../resources/addresses_rest_client_config.php', |
110 | 110 | ], |
111 | 111 | ], |
112 | | - 'operationsClientClass' => RegionOperationsClient::class, |
113 | 112 | ]; |
114 | 113 | } |
115 | 114 |
|
@@ -172,16 +171,35 @@ private function getDefaultOperationDescriptor() |
172 | 171 | */ |
173 | 172 | public function resumeOperation($operationName, $methodName = null) |
174 | 173 | { |
175 | | - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); |
| 174 | + $options = $this->descriptors[$methodName]['longRunning'] ?? $this->getDefaultOperationDescriptor(); |
176 | 175 | $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); |
177 | 176 | $operation->reload(); |
178 | 177 | return $operation; |
179 | 178 | } |
180 | 179 |
|
| 180 | + /** |
| 181 | + * Create the default operation client for the service. |
| 182 | + * |
| 183 | + * @param array $options ClientOptions for the client. |
| 184 | + * |
| 185 | + * @return RegionOperationsClient |
| 186 | + */ |
| 187 | + private function createOperationsClient(array $options) |
| 188 | + { |
| 189 | + // Unset client-specific configuration options |
| 190 | + unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']); |
| 191 | + |
| 192 | + if (isset($options['operationsClient'])) { |
| 193 | + return $options['operationsClient']; |
| 194 | + } |
| 195 | + |
| 196 | + return new RegionOperationsClient($options); |
| 197 | + } |
| 198 | + |
181 | 199 | /** |
182 | 200 | * Constructor. |
183 | 201 | * |
184 | | - * @param array $options { |
| 202 | + * @param array|ClientOptions $options { |
185 | 203 | * Optional. Options for configuring the service API wrapper. |
186 | 204 | * |
187 | 205 | * @type string $apiEndpoint |
@@ -234,11 +252,13 @@ public function resumeOperation($operationName, $methodName = null) |
234 | 252 | * @type false|LoggerInterface $logger |
235 | 253 | * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the |
236 | 254 | * 'GOOGLE_SDK_PHP_LOGGING' environment flag |
| 255 | + * @type string $universeDomain |
| 256 | + * The service domain for the client. Defaults to 'googleapis.com'. |
237 | 257 | * } |
238 | 258 | * |
239 | 259 | * @throws ValidationException |
240 | 260 | */ |
241 | | - public function __construct(array $options = []) |
| 261 | + public function __construct(array|ClientOptions $options = []) |
242 | 262 | { |
243 | 263 | $clientOptions = $this->buildClientOptions($options); |
244 | 264 | $this->setClientOptions($clientOptions); |
|
0 commit comments