Skip to content

Commit

Permalink
feat(SecretManager): Introduce v1beta2 (#7166)
Browse files Browse the repository at this point in the history
  • Loading branch information
yash30201 committed Mar 22, 2024
1 parent dd12f36 commit c843cee
Show file tree
Hide file tree
Showing 56 changed files with 9,552 additions and 0 deletions.
Binary file added SecretManager/metadata/V1Beta2/Resources.php
Binary file not shown.
115 changes: 115 additions & 0 deletions SecretManager/metadata/V1Beta2/Service.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -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/&#42;/secrets/&#42;/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/&#42;/secrets/&#42;/versions/*` or
* `projects/&#42;/locations/&#42;/secrets/&#42;/versions/*`.
*
* `projects/&#42;/secrets/&#42;/versions/latest` or
* `projects/&#42;/locations/&#42;/secrets/&#42;/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]
@@ -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/&#42;/secrets/*` or `projects/&#42;/locations/&#42;/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]
@@ -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/&#42;/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]

0 comments on commit c843cee

Please sign in to comment.