Skip to content

Commit 670112d

Browse files
chore(php)!: migrate admin services to new LRO client (#8637)
* chore(php)!: migrate Spanner to new client surface PiperOrigin-RevId: 813877400 Source-Link: googleapis/googleapis@8731190 Source-Link: googleapis/googleapis-gen@a9c62d9 Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiYTljNjJkOTVmOTIyMTAwNWVhYTRmYjJhYjNjYzdkY2I2NWQwZGE1MiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 1010b2f commit 670112d

4 files changed

Lines changed: 42 additions & 4 deletions

File tree

Spanner/src/Admin/Database/V1/Client/DatabaseAdminClient.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use Google\ApiCore\CredentialsWrapper;
2929
use Google\ApiCore\GapicClientTrait;
3030
use Google\ApiCore\InsecureCredentialsWrapper;
31-
use Google\ApiCore\LongRunning\OperationsClient;
3231
use Google\ApiCore\OperationResponse;
3332
use Google\ApiCore\Options\ClientOptions;
3433
use Google\ApiCore\PagedListResponse;
@@ -78,6 +77,7 @@
7877
use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlRequest;
7978
use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseMetadata;
8079
use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest;
80+
use Google\LongRunning\Client\OperationsClient;
8181
use Google\LongRunning\Operation;
8282
use Grpc\ChannelCredentials;
8383
use GuzzleHttp\Promise\PromiseInterface;
@@ -208,6 +208,25 @@ public function resumeOperation($operationName, $methodName = null)
208208
return $operation;
209209
}
210210

211+
/**
212+
* Create the default operation client for the service.
213+
*
214+
* @param array $options ClientOptions for the client.
215+
*
216+
* @return OperationsClient
217+
*/
218+
private function createOperationsClient(array $options)
219+
{
220+
// Unset client-specific configuration options
221+
unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']);
222+
223+
if (isset($options['operationsClient'])) {
224+
return $options['operationsClient'];
225+
}
226+
227+
return new OperationsClient($options);
228+
}
229+
211230
/**
212231
* Formats a string containing the fully-qualified path to represent a backup
213232
* resource.

Spanner/src/Admin/Instance/V1/Client/InstanceAdminClient.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use Google\ApiCore\CredentialsWrapper;
2929
use Google\ApiCore\GapicClientTrait;
3030
use Google\ApiCore\InsecureCredentialsWrapper;
31-
use Google\ApiCore\LongRunning\OperationsClient;
3231
use Google\ApiCore\OperationResponse;
3332
use Google\ApiCore\Options\ClientOptions;
3433
use Google\ApiCore\PagedListResponse;
@@ -71,6 +70,7 @@
7170
use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstancePartitionMetadata;
7271
use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstancePartitionRequest;
7372
use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceRequest;
73+
use Google\LongRunning\Client\OperationsClient;
7474
use Google\LongRunning\Operation;
7575
use Grpc\ChannelCredentials;
7676
use GuzzleHttp\Promise\PromiseInterface;
@@ -209,6 +209,25 @@ public function resumeOperation($operationName, $methodName = null)
209209
return $operation;
210210
}
211211

212+
/**
213+
* Create the default operation client for the service.
214+
*
215+
* @param array $options ClientOptions for the client.
216+
*
217+
* @return OperationsClient
218+
*/
219+
private function createOperationsClient(array $options)
220+
{
221+
// Unset client-specific configuration options
222+
unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']);
223+
224+
if (isset($options['operationsClient'])) {
225+
return $options['operationsClient'];
226+
}
227+
228+
return new OperationsClient($options);
229+
}
230+
212231
/**
213232
* Formats a string containing the fully-qualified path to represent a instance
214233
* resource.

Spanner/tests/Unit/Admin/Database/V1/Client/DatabaseAdminClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
use Google\ApiCore\ApiException;
2626
use Google\ApiCore\CredentialsWrapper;
27-
use Google\ApiCore\LongRunning\OperationsClient;
2827
use Google\ApiCore\Testing\GeneratedTest;
2928
use Google\ApiCore\Testing\MockTransport;
3029
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
@@ -70,6 +69,7 @@
7069
use Google\Cloud\Spanner\Admin\Database\V1\UpdateBackupScheduleRequest;
7170
use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlRequest;
7271
use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest;
72+
use Google\LongRunning\Client\OperationsClient;
7373
use Google\LongRunning\GetOperationRequest;
7474
use Google\LongRunning\Operation;
7575
use Google\Protobuf\Any;

Spanner/tests/Unit/Admin/Instance/V1/Client/InstanceAdminClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
use Google\ApiCore\ApiException;
2626
use Google\ApiCore\CredentialsWrapper;
27-
use Google\ApiCore\LongRunning\OperationsClient;
2827
use Google\ApiCore\Testing\GeneratedTest;
2928
use Google\ApiCore\Testing\MockTransport;
3029
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
@@ -60,6 +59,7 @@
6059
use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceConfigRequest;
6160
use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstancePartitionRequest;
6261
use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceRequest;
62+
use Google\LongRunning\Client\OperationsClient;
6363
use Google\LongRunning\GetOperationRequest;
6464
use Google\LongRunning\Operation;
6565
use Google\Protobuf\Any;

0 commit comments

Comments
 (0)