-
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.
feat: Add support to generate client certificate and get connection i…
…nfo for auth proxy in AlloyDB v1 (#6663) PiperOrigin-RevId: 568860878 Source-Link: googleapis/googleapis@5601ad3 Source-Link: googleapis/googleapis-gen@a1f1322 Copy-Tag: eyJwIjoiQWxsb3lEYi8uT3dsQm90LnlhbWwiLCJoIjoiYTFmMTMyMjYwYWYyOGEzMzZmNDNkNWE3YTUzYmYzZTY2YTRiNzVlOCJ9
- Loading branch information
1 parent
a42e6c0
commit 15da635
Showing
16 changed files
with
1,375 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
76 changes: 76 additions & 0 deletions
76
AlloyDb/samples/V1/AlloyDBAdminClient/generate_client_certificate.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,76 @@ | ||
<?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 alloydb_v1_generated_AlloyDBAdmin_GenerateClientCertificate_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient; | ||
use Google\Cloud\AlloyDb\V1\GenerateClientCertificateRequest; | ||
use Google\Cloud\AlloyDb\V1\GenerateClientCertificateResponse; | ||
|
||
/** | ||
* Generate a client certificate signed by a Cluster CA. | ||
* The sole purpose of this endpoint is to support AlloyDB connectors and the | ||
* Auth Proxy client. The endpoint's behavior is subject to change without | ||
* notice, so do not rely on its behavior remaining constant. Future changes | ||
* will not break AlloyDB connectors or the Auth Proxy client. | ||
* | ||
* @param string $formattedParent The name of the parent resource. The required format is: | ||
* * projects/{project}/locations/{location}/clusters/{cluster} | ||
* Please see {@see AlloyDBAdminClient::clusterName()} for help formatting this field. | ||
*/ | ||
function generate_client_certificate_sample(string $formattedParent): void | ||
{ | ||
// Create a client. | ||
$alloyDBAdminClient = new AlloyDBAdminClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new GenerateClientCertificateRequest()) | ||
->setParent($formattedParent); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var GenerateClientCertificateResponse $response */ | ||
$response = $alloyDBAdminClient->generateClientCertificate($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 | ||
{ | ||
$formattedParent = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]'); | ||
|
||
generate_client_certificate_sample($formattedParent); | ||
} | ||
// [END alloydb_v1_generated_AlloyDBAdmin_GenerateClientCertificate_sync] |
77 changes: 77 additions & 0 deletions
77
AlloyDb/samples/V1/AlloyDBAdminClient/get_connection_info.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,77 @@ | ||
<?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 alloydb_v1_generated_AlloyDBAdmin_GetConnectionInfo_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient; | ||
use Google\Cloud\AlloyDb\V1\ConnectionInfo; | ||
use Google\Cloud\AlloyDb\V1\GetConnectionInfoRequest; | ||
|
||
/** | ||
* Get instance metadata used for a connection. | ||
* | ||
* @param string $formattedParent The name of the parent resource. The required format is: | ||
* projects/{project}/locations/{location}/clusters/{cluster}/instances/{instance} | ||
* Please see {@see AlloyDBAdminClient::instanceName()} for help formatting this field. | ||
*/ | ||
function get_connection_info_sample(string $formattedParent): void | ||
{ | ||
// Create a client. | ||
$alloyDBAdminClient = new AlloyDBAdminClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new GetConnectionInfoRequest()) | ||
->setParent($formattedParent); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var ConnectionInfo $response */ | ||
$response = $alloyDBAdminClient->getConnectionInfo($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 | ||
{ | ||
$formattedParent = AlloyDBAdminClient::instanceName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[CLUSTER]', | ||
'[INSTANCE]' | ||
); | ||
|
||
get_connection_info_sample($formattedParent); | ||
} | ||
// [END alloydb_v1_generated_AlloyDBAdmin_GetConnectionInfo_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.