-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(SecretManager): Introduce v1beta2 (#7166)
- Loading branch information
Showing
56 changed files
with
9,552 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
SecretManager/samples/V1beta2/SecretManagerServiceClient/access_secret_version.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,88 @@ | ||
<?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 secretmanager_v1beta2_generated_SecretManagerService_AccessSecretVersion_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\SecretManager\V1beta2\AccessSecretVersionRequest; | ||
use Google\Cloud\SecretManager\V1beta2\AccessSecretVersionResponse; | ||
use Google\Cloud\SecretManager\V1beta2\Client\SecretManagerServiceClient; | ||
|
||
/** | ||
* Accesses a | ||
* [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. This | ||
* call returns the secret data. | ||
* | ||
* `projects/*/secrets/*/versions/latest` is an alias to the most recently | ||
* created [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. | ||
* | ||
* @param string $formattedName The resource name of the | ||
* [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] in the | ||
* format `projects/*/secrets/*/versions/*` or | ||
* `projects/*/locations/*/secrets/*/versions/*`. | ||
* | ||
* `projects/*/secrets/*/versions/latest` or | ||
* `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most | ||
* recently created | ||
* [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. Please see | ||
* {@see SecretManagerServiceClient::secretVersionName()} for help formatting this field. | ||
*/ | ||
function access_secret_version_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$secretManagerServiceClient = new SecretManagerServiceClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new AccessSecretVersionRequest()) | ||
->setName($formattedName); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var AccessSecretVersionResponse $response */ | ||
$response = $secretManagerServiceClient->accessSecretVersion($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 | ||
{ | ||
$formattedName = SecretManagerServiceClient::secretVersionName( | ||
'[PROJECT]', | ||
'[SECRET]', | ||
'[SECRET_VERSION]' | ||
); | ||
|
||
access_secret_version_sample($formattedName); | ||
} | ||
// [END secretmanager_v1beta2_generated_SecretManagerService_AccessSecretVersion_sync] |
80 changes: 80 additions & 0 deletions
80
SecretManager/samples/V1beta2/SecretManagerServiceClient/add_secret_version.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,80 @@ | ||
<?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 secretmanager_v1beta2_generated_SecretManagerService_AddSecretVersion_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\SecretManager\V1beta2\AddSecretVersionRequest; | ||
use Google\Cloud\SecretManager\V1beta2\Client\SecretManagerServiceClient; | ||
use Google\Cloud\SecretManager\V1beta2\SecretPayload; | ||
use Google\Cloud\SecretManager\V1beta2\SecretVersion; | ||
|
||
/** | ||
* Creates a new | ||
* [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] | ||
* containing secret data and attaches it to an existing | ||
* [Secret][google.cloud.secretmanager.v1beta2.Secret]. | ||
* | ||
* @param string $formattedParent The resource name of the | ||
* [Secret][google.cloud.secretmanager.v1beta2.Secret] to associate with the | ||
* [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] in the | ||
* format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`. Please see | ||
* {@see SecretManagerServiceClient::secretName()} for help formatting this field. | ||
*/ | ||
function add_secret_version_sample(string $formattedParent): void | ||
{ | ||
// Create a client. | ||
$secretManagerServiceClient = new SecretManagerServiceClient(); | ||
|
||
// Prepare the request message. | ||
$payload = new SecretPayload(); | ||
$request = (new AddSecretVersionRequest()) | ||
->setParent($formattedParent) | ||
->setPayload($payload); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var SecretVersion $response */ | ||
$response = $secretManagerServiceClient->addSecretVersion($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 = SecretManagerServiceClient::secretName('[PROJECT]', '[SECRET]'); | ||
|
||
add_secret_version_sample($formattedParent); | ||
} | ||
// [END secretmanager_v1beta2_generated_SecretManagerService_AddSecretVersion_sync] |
84 changes: 84 additions & 0 deletions
84
SecretManager/samples/V1beta2/SecretManagerServiceClient/create_secret.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,84 @@ | ||
<?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 secretmanager_v1beta2_generated_SecretManagerService_CreateSecret_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\SecretManager\V1beta2\Client\SecretManagerServiceClient; | ||
use Google\Cloud\SecretManager\V1beta2\CreateSecretRequest; | ||
use Google\Cloud\SecretManager\V1beta2\Secret; | ||
|
||
/** | ||
* Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] | ||
* containing no | ||
* [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion]. | ||
* | ||
* @param string $formattedParent The resource name of the project to associate with the | ||
* [Secret][google.cloud.secretmanager.v1beta2.Secret], in the format | ||
* `projects/*` or `projects/*/locations/*`. Please see | ||
* {@see SecretManagerServiceClient::projectName()} for help formatting this field. | ||
* @param string $secretId This must be unique within the project. | ||
* | ||
* A secret ID is a string with a maximum length of 255 characters and can | ||
* contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and | ||
* underscore (`_`) characters. | ||
*/ | ||
function create_secret_sample(string $formattedParent, string $secretId): void | ||
{ | ||
// Create a client. | ||
$secretManagerServiceClient = new SecretManagerServiceClient(); | ||
|
||
// Prepare the request message. | ||
$secret = new Secret(); | ||
$request = (new CreateSecretRequest()) | ||
->setParent($formattedParent) | ||
->setSecretId($secretId) | ||
->setSecret($secret); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var Secret $response */ | ||
$response = $secretManagerServiceClient->createSecret($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 = SecretManagerServiceClient::projectName('[PROJECT]'); | ||
$secretId = '[SECRET_ID]'; | ||
|
||
create_secret_sample($formattedParent, $secretId); | ||
} | ||
// [END secretmanager_v1beta2_generated_SecretManagerService_CreateSecret_sync] |
Oops, something went wrong.