Skip to content

Commit

Permalink
feat: A new field preferred_secondary_zone is added to message `.go…
Browse files Browse the repository at this point in the history
…ogle.cloud.sql.v1beta4.CloneContext` (#7457)

feat: A new field `psa_write_endpoint` is added to message `.google.cloud.sql.v1beta4.ReplicationCluster`
feat: A new value `SWITCHOVER_TO_REPLICA` is added to enum `SqlOperationType`
feat: A new value `POSTGRES_16` is added to enum `SqlDatabaseVersion`
feat: A new value `MYSQL_8_4_0` is added to enum `SqlDatabaseVersion`
docs: A comment for field `preferred_zone` in message `.google.cloud.sql.v1beta4.CloneContext` is changed
docs: A comment for field `satisfies_pzs` in message `.google.cloud.sql.v1beta4.DatabaseInstance` is changed
docs: A comment for enum value `SWITCHOVER` in enum `SqlOperationType` is changed
PiperOrigin-RevId: 644510265
Source-Link: googleapis/googleapis@6f90365
Source-Link: googleapis/googleapis-gen@c35e4b1
Copy-Tag: eyJwIjoiU3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiYzM1ZTRiMWVhMTQyYzE0YTQ1NzE5MjU5NDBkOWI5YWVhYmE1MDM3NiJ9
  • Loading branch information
gcf-owl-bot[bot] authored Jun 21, 2024
1 parent 4403524 commit 8756416
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 28 deletions.
21 changes: 7 additions & 14 deletions Spanner/src/Admin/Database/V1/Client/DatabaseAdminClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public static function parseName(string $formattedName, string $template = null)
*/
public function __construct(array $options = [])
{
$options = $options + $this->getDefaultEmulatorConfig();
$options = $this->setDefaultEmulatorConfig($options);
$clientOptions = $this->buildClientOptions($options);
$this->setClientOptions($clientOptions);
$this->operationsClient = $this->createOperationsClient($clientOptions);
Expand Down Expand Up @@ -1047,28 +1047,21 @@ public function updateDatabaseDdl(UpdateDatabaseDdlRequest $request, array $call
}

/** Configure the gapic configuration to use a service emulator. */
private function getDefaultEmulatorConfig(): array
private function setDefaultEmulatorConfig(array $options): array
{
$emulatorHost = getenv('SPANNER_EMULATOR_HOST');
if (empty($emulatorHost)) {
return [];
return $options;
}

if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) {
$search = $scheme . '://';
$emulatorHost = str_replace($search, '', $emulatorHost);
}

return [
'apiEndpoint' => $emulatorHost,
'transportConfig' => [
'grpc' => [
'stubOpts' => [
'credentials' => ChannelCredentials::createInsecure(),
],
],
],
'credentials' => new InsecureCredentialsWrapper(),
];
$options['apiEndpoint'] ??= $emulatorHost;
$options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure();
$options['credentials'] ??= new InsecureCredentialsWrapper();
return $options;
}
}
21 changes: 7 additions & 14 deletions Spanner/src/Admin/Instance/V1/Client/InstanceAdminClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public static function parseName(string $formattedName, string $template = null)
*/
public function __construct(array $options = [])
{
$options = $options + $this->getDefaultEmulatorConfig();
$options = $this->setDefaultEmulatorConfig($options);
$clientOptions = $this->buildClientOptions($options);
$this->setClientOptions($clientOptions);
$this->operationsClient = $this->createOperationsClient($clientOptions);
Expand Down Expand Up @@ -1189,28 +1189,21 @@ public function updateInstancePartition(UpdateInstancePartitionRequest $request,
}

/** Configure the gapic configuration to use a service emulator. */
private function getDefaultEmulatorConfig(): array
private function setDefaultEmulatorConfig(array $options): array
{
$emulatorHost = getenv('SPANNER_EMULATOR_HOST');
if (empty($emulatorHost)) {
return [];
return $options;
}

if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) {
$search = $scheme . '://';
$emulatorHost = str_replace($search, '', $emulatorHost);
}

return [
'apiEndpoint' => $emulatorHost,
'transportConfig' => [
'grpc' => [
'stubOpts' => [
'credentials' => ChannelCredentials::createInsecure(),
],
],
],
'credentials' => new InsecureCredentialsWrapper(),
];
$options['apiEndpoint'] ??= $emulatorHost;
$options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure();
$options['credentials'] ??= new InsecureCredentialsWrapper();
return $options;
}
}
26 changes: 26 additions & 0 deletions Spanner/src/V1/Client/SpannerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Google\ApiCore\ApiException;
use Google\ApiCore\CredentialsWrapper;
use Google\ApiCore\GapicClientTrait;
use Google\ApiCore\InsecureCredentialsWrapper;
use Google\ApiCore\PagedListResponse;
use Google\ApiCore\ResourceHelperTrait;
use Google\ApiCore\RetrySettings;
Expand Down Expand Up @@ -57,6 +58,7 @@
use Google\Cloud\Spanner\V1\RollbackRequest;
use Google\Cloud\Spanner\V1\Session;
use Google\Cloud\Spanner\V1\Transaction;
use Grpc\ChannelCredentials;
use GuzzleHttp\Promise\PromiseInterface;

/**
Expand Down Expand Up @@ -204,6 +206,10 @@ public static function parseName(string $formattedName, string $template = null)
/**
* Constructor.
*
* Setting the "SPANNER_EMULATOR_HOST" environment variable will automatically set
* the API Endpoint to the value specified in the variable, as well as ensure that
* empty credentials are used in the transport layer.
*
* @param array $options {
* Optional. Options for configuring the service API wrapper.
*
Expand Down Expand Up @@ -257,6 +263,7 @@ public static function parseName(string $formattedName, string $template = null)
*/
public function __construct(array $options = [])
{
$options = $this->setDefaultEmulatorConfig($options);
$clientOptions = $this->buildClientOptions($options);
$this->setClientOptions($clientOptions);
}
Expand Down Expand Up @@ -803,4 +810,23 @@ public function streamingRead(ReadRequest $request, array $callOptions = []): Se
{
return $this->startApiCall('StreamingRead', $request, $callOptions);
}

/** Configure the gapic configuration to use a service emulator. */
private function setDefaultEmulatorConfig(array $options): array
{
$emulatorHost = getenv('SPANNER_EMULATOR_HOST');
if (empty($emulatorHost)) {
return $options;
}

if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) {
$search = $scheme . '://';
$emulatorHost = str_replace($search, '', $emulatorHost);
}

$options['apiEndpoint'] ??= $emulatorHost;
$options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure();
$options['credentials'] ??= new InsecureCredentialsWrapper();
return $options;
}
}

0 comments on commit 8756416

Please sign in to comment.