-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PiperOrigin-RevId: 586089229 Source-Link: googleapis/googleapis@f5d61d7 Source-Link: googleapis/googleapis-gen@6236bbe Copy-Tag: eyJwIjoiU3FsQWRtaW4vLk93bEJvdC55YW1sIiwiaCI6IjYyMzZiYmU3NDdhOWY4OTRlNDFlNGJlZmVmZGQ2MjliMjY2MTgzNTEifQ== * feat: added Demote RPC PiperOrigin-RevId: 586090177 Source-Link: googleapis/googleapis@f10a004 Source-Link: googleapis/googleapis-gen@5e21cf0 Copy-Tag: eyJwIjoiU3FsQWRtaW4vLk93bEJvdC55YW1sIiwiaCI6IjVlMjFjZjAxMTY3Y2VkNzhjN2FkYjJjYjZmZjQ0YzkyYTM1MWQ3MWYifQ==
- Loading branch information
1 parent
8a35600
commit 7c9fc72
Showing
22 changed files
with
1,156 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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 sqladmin_v1_generated_SqlInstancesService_Demote_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient; | ||
use Google\Cloud\Sql\V1\DemoteContext; | ||
use Google\Cloud\Sql\V1\InstancesDemoteRequest; | ||
use Google\Cloud\Sql\V1\Operation; | ||
use Google\Cloud\Sql\V1\SqlInstancesDemoteRequest; | ||
|
||
/** | ||
* Demotes an existing standalone instance to be a Cloud SQL read replica | ||
* for an external database server. | ||
* | ||
* @param string $instance Cloud SQL instance name. | ||
* @param string $project ID of the project that contains the instance. | ||
* @param string $bodyDemoteContextSourceRepresentativeInstanceName The name of the instance which acts as the on-premises primary | ||
* instance in the replication setup. | ||
*/ | ||
function demote_sample( | ||
string $instance, | ||
string $project, | ||
string $bodyDemoteContextSourceRepresentativeInstanceName | ||
): void { | ||
// Create a client. | ||
$sqlInstancesServiceClient = new SqlInstancesServiceClient(); | ||
|
||
// Prepare the request message. | ||
$bodyDemoteContext = (new DemoteContext()) | ||
->setSourceRepresentativeInstanceName($bodyDemoteContextSourceRepresentativeInstanceName); | ||
$body = (new InstancesDemoteRequest()) | ||
->setDemoteContext($bodyDemoteContext); | ||
$request = (new SqlInstancesDemoteRequest()) | ||
->setInstance($instance) | ||
->setProject($project) | ||
->setBody($body); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var Operation $response */ | ||
$response = $sqlInstancesServiceClient->demote($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 | ||
{ | ||
$instance = '[INSTANCE]'; | ||
$project = '[PROJECT]'; | ||
$bodyDemoteContextSourceRepresentativeInstanceName = '[SOURCE_REPRESENTATIVE_INSTANCE_NAME]'; | ||
|
||
demote_sample($instance, $project, $bodyDemoteContextSourceRepresentativeInstanceName); | ||
} | ||
// [END sqladmin_v1_generated_SqlInstancesService_Demote_sync] |
68 changes: 68 additions & 0 deletions
68
SqlAdmin/samples/V1beta4/SqlInstancesServiceClient/demote.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,68 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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 sqladmin_v1beta4_generated_SqlInstancesService_Demote_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Sql\V1beta4\Operation; | ||
use Google\Cloud\Sql\V1beta4\SqlInstancesServiceClient; | ||
|
||
/** | ||
* Demotes an existing standalone instance to be a Cloud SQL read replica | ||
* for an external database server. | ||
* | ||
* @param string $instance The name of the Cloud SQL instance. | ||
* @param string $project The project ID of the project that contains the instance. | ||
*/ | ||
function demote_sample(string $instance, string $project): void | ||
{ | ||
// Create a client. | ||
$sqlInstancesServiceClient = new SqlInstancesServiceClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var Operation $response */ | ||
$response = $sqlInstancesServiceClient->demote($instance, $project); | ||
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 | ||
{ | ||
$instance = '[INSTANCE]'; | ||
$project = '[PROJECT]'; | ||
|
||
demote_sample($instance, $project); | ||
} | ||
// [END sqladmin_v1beta4_generated_SqlInstancesService_Demote_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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.