-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new PSC instance configuration setting and output the PSC D…
…NS name (#7760) feat: add new API to execute SQL statements feat: add support for Free Trials feat: add support to schedule maintenance feat: additional field to set tags on a backup or cluster feat: add more observability options on the Instance level feat: add new API to perform a promotion or switchover on secondary instances feat: support for obtaining the public ip addresses of an instance and enabling either inbound or outbound public ip feat: add new API to list the databases in a project and location feat: add optional field to keep extra roles on a user if it already exists docs: various typo fixes, correcting the formatting, and clarifications on the request_id and validate_only fields in API requests and on the page_size when listing the database PiperOrigin-RevId: 688544999 Source-Link: googleapis/googleapis@113ddfe Source-Link: googleapis/googleapis-gen@14fa50e Copy-Tag: eyJwIjoiQWxsb3lEYi8uT3dsQm90LnlhbWwiLCJoIjoiMTRmYTUwZWRkNTc2MjlhYjMxOGJiN2I5OGE3Mjg2YjQ2NzQ5ZThkZiJ9
- Loading branch information
1 parent
3b5afb3
commit 22357f5
Showing
69 changed files
with
4,856 additions
and
594 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START alloydb_v1_generated_AlloyDBAdmin_ExecuteSql_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient; | ||
use Google\Cloud\AlloyDb\V1\ExecuteSqlRequest; | ||
use Google\Cloud\AlloyDb\V1\ExecuteSqlResponse; | ||
|
||
/** | ||
* Executes a SQL statement in a database inside an AlloyDB instance. | ||
* | ||
* @param string $formattedInstance The instance where the SQL will be executed. For the required | ||
* format, see the comment on the Instance.name field. Please see | ||
* {@see AlloyDBAdminClient::instanceName()} for help formatting this field. | ||
* @param string $database Name of the database where the query will be executed. | ||
* Note - Value provided should be the same as expected from `SELECT | ||
* current_database();` and NOT as a resource reference. | ||
* @param string $user Database user to be used for executing the SQL. | ||
* Note - Value provided should be the same as expected from | ||
* `SELECT current_user;` and NOT as a resource reference. | ||
* @param string $sqlStatement SQL statement to execute on database. Any valid statement is | ||
* permitted, including DDL, DML, DQL statements. | ||
*/ | ||
function execute_sql_sample( | ||
string $formattedInstance, | ||
string $database, | ||
string $user, | ||
string $sqlStatement | ||
): void { | ||
// Create a client. | ||
$alloyDBAdminClient = new AlloyDBAdminClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new ExecuteSqlRequest()) | ||
->setInstance($formattedInstance) | ||
->setDatabase($database) | ||
->setUser($user) | ||
->setSqlStatement($sqlStatement); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var ExecuteSqlResponse $response */ | ||
$response = $alloyDBAdminClient->executeSql($request); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedInstance = AlloyDBAdminClient::instanceName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[CLUSTER]', | ||
'[INSTANCE]' | ||
); | ||
$database = '[DATABASE]'; | ||
$user = '[USER]'; | ||
$sqlStatement = '[SQL_STATEMENT]'; | ||
|
||
execute_sql_sample($formattedInstance, $database, $user, $sqlStatement); | ||
} | ||
// [END alloydb_v1_generated_AlloyDBAdmin_ExecuteSql_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START alloydb_v1_generated_AlloyDBAdmin_ListDatabases_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\PagedListResponse; | ||
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient; | ||
use Google\Cloud\AlloyDb\V1\Database; | ||
use Google\Cloud\AlloyDb\V1\ListDatabasesRequest; | ||
|
||
/** | ||
* Lists Databases in a given project and location. | ||
* | ||
* @param string $formattedParent Parent value for ListDatabasesRequest. Please see | ||
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field. | ||
*/ | ||
function list_databases_sample(string $formattedParent): void | ||
{ | ||
// Create a client. | ||
$alloyDBAdminClient = new AlloyDBAdminClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new ListDatabasesRequest()) | ||
->setParent($formattedParent); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var PagedListResponse $response */ | ||
$response = $alloyDBAdminClient->listDatabases($request); | ||
|
||
/** @var Database $element */ | ||
foreach ($response as $element) { | ||
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedParent = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]'); | ||
|
||
list_databases_sample($formattedParent); | ||
} | ||
// [END alloydb_v1_generated_AlloyDBAdmin_ListDatabases_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
AlloyDb/samples/V1/AlloyDBAdminClient/switchover_cluster.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START alloydb_v1_generated_AlloyDBAdmin_SwitchoverCluster_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient; | ||
use Google\Cloud\AlloyDb\V1\Cluster; | ||
use Google\Cloud\AlloyDb\V1\SwitchoverClusterRequest; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Switches the roles of PRIMARY and SECONDARY clusters without any data loss. | ||
* This promotes the SECONDARY cluster to PRIMARY and sets up the original | ||
* PRIMARY cluster to replicate from this newly promoted cluster. | ||
* | ||
* @param string $formattedName The name of the resource. For the required format, see the | ||
* comment on the Cluster.name field | ||
* Please see {@see AlloyDBAdminClient::clusterName()} for help formatting this field. | ||
*/ | ||
function switchover_cluster_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$alloyDBAdminClient = new AlloyDBAdminClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new SwitchoverClusterRequest()) | ||
->setName($formattedName); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $alloyDBAdminClient->switchoverCluster($request); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var Cluster $result */ | ||
$result = $response->getResult(); | ||
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); | ||
} else { | ||
/** @var Status $error */ | ||
$error = $response->getError(); | ||
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); | ||
} | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedName = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]'); | ||
|
||
switchover_cluster_sample($formattedName); | ||
} | ||
// [END alloydb_v1_generated_AlloyDBAdmin_SwitchoverCluster_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.