Skip to content

Commit

Permalink
feat: add new PSC instance configuration setting and output the PSC D…
Browse files Browse the repository at this point in the history
…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
gcf-owl-bot[bot] authored Oct 24, 2024
1 parent 3b5afb3 commit 22357f5
Show file tree
Hide file tree
Showing 69 changed files with 4,856 additions and 594 deletions.
Binary file added AlloyDb/metadata/V1/DataModel.php
Binary file not shown.
Binary file modified AlloyDb/metadata/V1/Resources.php
Binary file not shown.
Binary file modified AlloyDb/metadata/V1/Service.php
Binary file not shown.
2 changes: 1 addition & 1 deletion AlloyDb/samples/V1/AlloyDBAdminClient/create_cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @param string $formattedClusterNetwork The resource link for the VPC network in which cluster resources
* are created and from which they are accessible via Private IP. The network
* must belong to the same project as the cluster. It is specified in the
* form: "projects/{project}/global/networks/{network_id}". This is required
* form: `projects/{project}/global/networks/{network_id}`. This is required
* to create a cluster. Deprecated, use network_config.network instead. Please see
* {@see AlloyDBAdminClient::networkName()} for help formatting this field.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @param string $formattedClusterNetwork The resource link for the VPC network in which cluster resources
* are created and from which they are accessible via Private IP. The network
* must belong to the same project as the cluster. It is specified in the
* form: "projects/{project}/global/networks/{network_id}". This is required
* form: `projects/{project}/global/networks/{network_id}`. This is required
* to create a cluster. Deprecated, use network_config.network instead. Please see
* {@see AlloyDBAdminClient::networkName()} for help formatting this field.
*/
Expand Down
95 changes: 95 additions & 0 deletions AlloyDb/samples/V1/AlloyDBAdminClient/execute_sql.php
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]
76 changes: 76 additions & 0 deletions AlloyDb/samples/V1/AlloyDBAdminClient/list_databases.php
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]
2 changes: 1 addition & 1 deletion AlloyDb/samples/V1/AlloyDBAdminClient/restore_cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @param string $formattedClusterNetwork The resource link for the VPC network in which cluster resources
* are created and from which they are accessible via Private IP. The network
* must belong to the same project as the cluster. It is specified in the
* form: "projects/{project}/global/networks/{network_id}". This is required
* form: `projects/{project}/global/networks/{network_id}`. This is required
* to create a cluster. Deprecated, use network_config.network instead. Please see
* {@see AlloyDBAdminClient::networkName()} for help formatting this field.
*/
Expand Down
86 changes: 86 additions & 0 deletions AlloyDb/samples/V1/AlloyDBAdminClient/switchover_cluster.php
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]
2 changes: 1 addition & 1 deletion AlloyDb/samples/V1/AlloyDBAdminClient/update_cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @param string $formattedClusterNetwork The resource link for the VPC network in which cluster resources
* are created and from which they are accessible via Private IP. The network
* must belong to the same project as the cluster. It is specified in the
* form: "projects/{project}/global/networks/{network_id}". This is required
* form: `projects/{project}/global/networks/{network_id}`. This is required
* to create a cluster. Deprecated, use network_config.network instead. Please see
* {@see AlloyDBAdminClient::networkName()} for help formatting this field.
*/
Expand Down
Loading

0 comments on commit 22357f5

Please sign in to comment.