diff --git a/secretmanager/composer.json b/secretmanager/composer.json index 6f155f1b7..5f4cb72b0 100644 --- a/secretmanager/composer.json +++ b/secretmanager/composer.json @@ -1,5 +1,5 @@ { "require": { - "google/cloud-secret-manager": "^1.12.2" + "google/cloud-secret-manager": "^1.12" } } diff --git a/secretmanager/quickstart.php b/secretmanager/quickstart.php index 0ac760fec..5fce12f84 100644 --- a/secretmanager/quickstart.php +++ b/secretmanager/quickstart.php @@ -26,10 +26,13 @@ // [START secretmanager_quickstart] // Import the Secret Manager client library. +use Google\Cloud\SecretManager\V1\AccessSecretVersionRequest; +use Google\Cloud\SecretManager\V1\AddSecretVersionRequest; +use Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient; +use Google\Cloud\SecretManager\V1\CreateSecretRequest; use Google\Cloud\SecretManager\V1\Replication; use Google\Cloud\SecretManager\V1\Replication\Automatic; use Google\Cloud\SecretManager\V1\Secret; -use Google\Cloud\SecretManager\V1\SecretManagerServiceClient; use Google\Cloud\SecretManager\V1\SecretPayload; /** Uncomment and populate these variables in your code */ @@ -43,21 +46,28 @@ $parent = $client->projectName($projectId); // Create the parent secret. -$secret = $client->createSecret($parent, $secretId, - new Secret([ +$createSecretRequest = (new CreateSecretRequest()) + ->setParent($parent) + ->setSecretId($secretId) + ->setSecret(new Secret([ 'replication' => new Replication([ 'automatic' => new Automatic(), ]), - ]) -); + ])); +$secret = $client->createSecret($createSecretRequest); // Add the secret version. -$version = $client->addSecretVersion($secret->getName(), new SecretPayload([ +$addSecretVersionRequest = (new AddSecretVersionRequest()) + ->setParent($secret->getName()) + ->setPayload(new SecretPayload([ 'data' => 'hello world', ])); +$version = $client->addSecretVersion($addSecretVersionRequest); // Access the secret version. -$response = $client->accessSecretVersion($version->getName()); +$accessSecretVersionRequest = (new AccessSecretVersionRequest()) + ->setName($version->getName()); +$response = $client->accessSecretVersion($accessSecretVersionRequest); // Print the secret payload. //