From 6532eabad24c4a7ea980470da42f37be3d991a8a Mon Sep 17 00:00:00 2001 From: Kapish Date: Thu, 29 Aug 2024 06:54:10 +0000 Subject: [PATCH 1/8] Added regional secrets samples and test --- secretmanager/composer.json | 2 +- .../src/access_regional_secret_version.php | 67 ++++ .../src/add_regional_secret_version.php | 66 ++++ secretmanager/src/create_regional_secret.php | 65 ++++ secretmanager/src/delete_regional_secret.php | 60 ++++ .../src/destroy_regional_secret_version.php | 63 ++++ .../src/disable_regional_secret_version.php | 63 ++++ .../src/enable_regional_secret_version.php | 63 ++++ secretmanager/src/get_regional_secret.php | 62 ++++ .../src/get_regional_secret_version.php | 67 ++++ .../src/list_regional_secret_versions.php | 61 ++++ secretmanager/src/list_regional_secrets.php | 60 ++++ .../src/regional_iam_grant_access.php | 80 +++++ .../src/regional_iam_revoke_access.php | 83 +++++ secretmanager/src/update_regional_secret.php | 71 ++++ .../src/update_regional_secret_with_alias.php | 71 ++++ .../test/regionalsecretmanagerTest.php | 328 ++++++++++++++++++ 17 files changed, 1331 insertions(+), 1 deletion(-) create mode 100644 secretmanager/src/access_regional_secret_version.php create mode 100644 secretmanager/src/add_regional_secret_version.php create mode 100644 secretmanager/src/create_regional_secret.php create mode 100644 secretmanager/src/delete_regional_secret.php create mode 100644 secretmanager/src/destroy_regional_secret_version.php create mode 100644 secretmanager/src/disable_regional_secret_version.php create mode 100644 secretmanager/src/enable_regional_secret_version.php create mode 100644 secretmanager/src/get_regional_secret.php create mode 100644 secretmanager/src/get_regional_secret_version.php create mode 100644 secretmanager/src/list_regional_secret_versions.php create mode 100644 secretmanager/src/list_regional_secrets.php create mode 100644 secretmanager/src/regional_iam_grant_access.php create mode 100644 secretmanager/src/regional_iam_revoke_access.php create mode 100644 secretmanager/src/update_regional_secret.php create mode 100644 secretmanager/src/update_regional_secret_with_alias.php create mode 100644 secretmanager/test/regionalsecretmanagerTest.php diff --git a/secretmanager/composer.json b/secretmanager/composer.json index c52bc1c5b4..ad1f41e13f 100644 --- a/secretmanager/composer.json +++ b/secretmanager/composer.json @@ -1,5 +1,5 @@ { "require": { - "google/cloud-secret-manager": "^1.13" + "google/cloud-secret-manager": "^1.15.2" } } diff --git a/secretmanager/src/access_regional_secret_version.php b/secretmanager/src/access_regional_secret_version.php new file mode 100644 index 0000000000..f9e5d6323d --- /dev/null +++ b/secretmanager/src/access_regional_secret_version.php @@ -0,0 +1,67 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret version. + $name = $client->projectLocationSecretSecretVersionName($projectId, $locationId, $secretId, $versionId); + + // Build the request. + $request = AccessSecretVersionRequest::build($name); + + // Access the secret version. + $response = $client->accessSecretVersion($request); + + // Print the secret payload. + // + // WARNING: Do not print the secret in a production environment - this + // snippet is showing how to access the secret material. + $payload = $response->getPayload()->getData(); + printf('Plaintext: %s', $payload); +} +// [END secretmanager_access_regional_secret_version] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/add_regional_secret_version.php b/secretmanager/src/add_regional_secret_version.php new file mode 100644 index 0000000000..465dc388ac --- /dev/null +++ b/secretmanager/src/add_regional_secret_version.php @@ -0,0 +1,66 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the parent secret and the payload. + $parent = $client->projectLocationSecretName($projectId, $locationId, $secretId); + $secretPayload = new SecretPayload([ + 'data' => 'my super secret data', + ]); + + // Build the request. + $request = AddSecretVersionRequest::build($parent, $secretPayload); + + // Access the secret version. + $response = $client->addSecretVersion($request); + + // Print the new secret version name. + printf('Added secret version: %s', $response->getName()); +} +// [END secretmanager_add_regional_secret_version] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/create_regional_secret.php b/secretmanager/src/create_regional_secret.php new file mode 100644 index 0000000000..68f98b9a77 --- /dev/null +++ b/secretmanager/src/create_regional_secret.php @@ -0,0 +1,65 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the parent project. + $parent = $client->locationName($projectId, $locationId); + + $secret = new Secret(); + + // Build the request. + $request = CreateSecretRequest::build($parent, $secretId, $secret); + + // Create the secret. + $newSecret = $client->createSecret($request); + + // Print the new secret name. + printf('Created secret: %s', $newSecret->getName()); +} +// [END secretmanager_create_regional_secret] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/delete_regional_secret.php b/secretmanager/src/delete_regional_secret.php new file mode 100644 index 0000000000..60d503c37e --- /dev/null +++ b/secretmanager/src/delete_regional_secret.php @@ -0,0 +1,60 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret. + $name = $client->projectLocationSecretName($projectId, $locationId, $secretId); + + // Build the request. + $request = DeleteSecretRequest::build($name); + + // Delete the secret. + $client->deleteSecret($request); + printf('Deleted secret %s', $secretId); +} +// [END secretmanager_delete_regional_secret] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/destroy_regional_secret_version.php b/secretmanager/src/destroy_regional_secret_version.php new file mode 100644 index 0000000000..e8f0cab7d2 --- /dev/null +++ b/secretmanager/src/destroy_regional_secret_version.php @@ -0,0 +1,63 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret version. + $name = $client->projectLocationSecretSecretVersionName($projectId, $locationId, $secretId, $versionId); + + // Build the request. + $request = DestroySecretVersionRequest::build($name); + + // Destroy the secret version. + $response = $client->destroySecretVersion($request); + + // Print a success message. + printf('Destroyed secret version: %s', $response->getName()); +} +// [END secretmanager_destroy_regional_secret_version] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/disable_regional_secret_version.php b/secretmanager/src/disable_regional_secret_version.php new file mode 100644 index 0000000000..a2cbc56d0a --- /dev/null +++ b/secretmanager/src/disable_regional_secret_version.php @@ -0,0 +1,63 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret version. + $name = $client->projectLocationSecretSecretVersionName($projectId, $locationId, $secretId, $versionId); + + // Build the request. + $request = DisableSecretVersionRequest::build($name); + + // Disable the secret version. + $response = $client->disableSecretVersion($request); + + // Print a success message. + printf('Disabled secret version: %s', $response->getName()); +} +// [END secretmanager_disable_regional_secret_version] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/enable_regional_secret_version.php b/secretmanager/src/enable_regional_secret_version.php new file mode 100644 index 0000000000..82a7e902a3 --- /dev/null +++ b/secretmanager/src/enable_regional_secret_version.php @@ -0,0 +1,63 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret version. + $name = $client->projectLocationSecretSecretVersionName($projectId, $locationId, $secretId, $versionId); + + // Build the request. + $request = EnableSecretVersionRequest::build($name); + + // Enable the secret version. + $response = $client->enableSecretVersion($request); + + // Print a success message. + printf('Enabled secret version: %s', $response->getName()); +} +// [END secretmanager_enable_regional_secret_version] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/get_regional_secret.php b/secretmanager/src/get_regional_secret.php new file mode 100644 index 0000000000..3c5b6e49e0 --- /dev/null +++ b/secretmanager/src/get_regional_secret.php @@ -0,0 +1,62 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret. + $name = $client->projectLocationSecretName($projectId, $locationId, $secretId); + + // Build the request. + $request = GetSecretRequest::build($name); + + // Get the secret. + $secret = $client->getSecret($request); + + // Print data about the secret. + printf('Got secret %s ', $secret->getName()); +} +// [END secretmanager_get_regional_secret] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/get_regional_secret_version.php b/secretmanager/src/get_regional_secret_version.php new file mode 100644 index 0000000000..6f785253d6 --- /dev/null +++ b/secretmanager/src/get_regional_secret_version.php @@ -0,0 +1,67 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret version. + $name = $client->projectLocationSecretSecretVersionName($projectId, $locationId, $secretId, $versionId); + + // Build the request. + $request = GetSecretVersionRequest::build($name); + + // Access the secret version. + $response = $client->getSecretVersion($request); + + // Get the state string from the enum. + $state = State::name($response->getState()); + + // Print a success message. + printf('Got secret version %s with state %s', $response->getName(), $state); +} +// [END secretmanager_get_regional_secret_version] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/list_regional_secret_versions.php b/secretmanager/src/list_regional_secret_versions.php new file mode 100644 index 0000000000..395270c14a --- /dev/null +++ b/secretmanager/src/list_regional_secret_versions.php @@ -0,0 +1,61 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the parent secret. + $parent = $client->projectLocationSecretName($projectId, $locationId, $secretId); + + // Build the request. + $request = ListSecretVersionsRequest::build($parent); + + // List all secret versions. + foreach ($client->listSecretVersions($request) as $version) { + printf('Found secret version %s', $version->getName()); + } +} +// [END secretmanager_list_regional_secret_versions] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/list_regional_secrets.php b/secretmanager/src/list_regional_secrets.php new file mode 100644 index 0000000000..85303665ee --- /dev/null +++ b/secretmanager/src/list_regional_secrets.php @@ -0,0 +1,60 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the parent secret. + $parent = $client->locationName($projectId, $locationId); + + // Build the request. + $request = ListSecretsRequest::build($parent); + + // List all secrets. + foreach ($client->listSecrets($request) as $secret) { + printf('Found secret %s', $secret->getName()); + } +} +// [END secretmanager_list_regional_secret] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/regional_iam_grant_access.php b/secretmanager/src/regional_iam_grant_access.php new file mode 100644 index 0000000000..b649b2b2a1 --- /dev/null +++ b/secretmanager/src/regional_iam_grant_access.php @@ -0,0 +1,80 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret. + $name = $client->projectLocationSecretName($projectId, $locationId, $secretId); + + // Get the current IAM policy. + $policy = $client->getIamPolicy((new GetIamPolicyRequest)->setResource($name)); + + // Update the bindings to include the new member. + $bindings = $policy->getBindings(); + $bindings[] = new Binding([ + 'members' => [$member], + 'role' => 'roles/secretmanager.secretAccessor', + ]); + $policy->setBindings($bindings); + + // Build the request. + $request = (new SetIamPolicyRequest) + ->setResource($name) + ->setPolicy($policy); + + // Save the updated policy to the server. + $client->setIamPolicy($request); + + // Print out a success message. + printf('Updated IAM policy for %s', $secretId); +} +// [END secretmanager_regional_iam_grant_access] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/regional_iam_revoke_access.php b/secretmanager/src/regional_iam_revoke_access.php new file mode 100644 index 0000000000..06caf701d3 --- /dev/null +++ b/secretmanager/src/regional_iam_revoke_access.php @@ -0,0 +1,83 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret. + $name = $client->projectLocationSecretName($projectId, $locationId, $secretId); + + // Get the current IAM policy. + $policy = $client->getIamPolicy((new GetIamPolicyRequest)->setResource($name)); + + // Remove the member from the list of bindings. + foreach ($policy->getBindings() as $binding) { + if ($binding->getRole() == 'roles/secretmanager.secretAccessor') { + $members = $binding->getMembers(); + foreach ($members as $i => $existingMember) { + if ($member == $existingMember) { + unset($members[$i]); + $binding->setMembers($members); + break; + } + } + } + } + + // Build the request. + $request = (new SetIamPolicyRequest) + ->setResource($name) + ->setPolicy($policy); + + // Save the updated policy to the server. + $client->setIamPolicy($request); + + // Print out a success message. + printf('Updated IAM policy for %s', $secretId); +} +// [END secretmanager_regional_iam_revoke_access] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/update_regional_secret.php b/secretmanager/src/update_regional_secret.php new file mode 100644 index 0000000000..fe5cda1fe9 --- /dev/null +++ b/secretmanager/src/update_regional_secret.php @@ -0,0 +1,71 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret. + $name = $client->projectLocationSecretName($projectId, $locationId, $secretId); + + // Update the secret. + $secret = (new Secret()) + ->setName($name) + ->setLabels(['secretmanager' => 'rocks']); + + $updateMask = (new FieldMask()) + ->setPaths(['labels']); + + // Build the request. + $request = UpdateSecretRequest::build($secret, $updateMask); + + $response = $client->updateSecret($request); + + // Print the upated secret. + printf('Updated secret: %s', $response->getName()); +} +// [END secretmanager_update_regional_secret] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/update_regional_secret_with_alias.php b/secretmanager/src/update_regional_secret_with_alias.php new file mode 100644 index 0000000000..aaa43cbc2f --- /dev/null +++ b/secretmanager/src/update_regional_secret_with_alias.php @@ -0,0 +1,71 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + + // Create the Secret Manager client. + $client = new SecretManagerServiceClient($options); + + // Build the resource name of the secret. + $name = $client->projectLocationSecretName($projectId, $locationId, $secretId); + + // Update the secret. + $secret = (new Secret()) + ->setName($name) + ->setVersionAliases(['test' => '1']); + + $updateMask = (new FieldMask()) + ->setPaths(['version_aliases']); + + // Build the request. + $request = UpdateSecretRequest::build($secret, $updateMask); + + $response = $client->updateSecret($request); + + // Print the upated secret. + printf('Updated secret: %s', $response->getName()); +} +// [END secretmanager_update_regional_secret_with_alias] + +// The following 2 lines are only needed to execute the samples on the CLI +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/test/regionalsecretmanagerTest.php b/secretmanager/test/regionalsecretmanagerTest.php new file mode 100644 index 0000000000..6a19d2ce16 --- /dev/null +++ b/secretmanager/test/regionalsecretmanagerTest.php @@ -0,0 +1,328 @@ + "secretmanager.$locationId.rep.googleapis.com"]; + self::$client = new SecretManagerServiceClient($options); + + self::$testSecret = self::createSecret(); + self::$testSecretToDelete = self::createSecret(); + self::$testSecretWithVersions = self::createSecret(); + self::$testSecretToCreateName = self::$client->secretName(self::$projectId, self::randomSecretId()); + self::$testUmmrSecretToCreateName = self::$client->secretName(self::$projectId, self::randomSecretId()); + + self::$testSecretVersion = self::addSecretVersion(self::$testSecretWithVersions); + self::$testSecretVersionToDestroy = self::addSecretVersion(self::$testSecretWithVersions); + self::$testSecretVersionToDisable = self::addSecretVersion(self::$testSecretWithVersions); + self::$testSecretVersionToEnable = self::addSecretVersion(self::$testSecretWithVersions); + self::disableSecretVersion(self::$testSecretVersionToEnable); + } + + public static function tearDownAfterClass(): void + { + self::deleteSecret(self::$testSecret->getName()); + self::deleteSecret(self::$testSecretToDelete->getName()); + self::deleteSecret(self::$testSecretWithVersions->getName()); + self::deleteSecret(self::$testSecretToCreateName); + self::deleteSecret(self::$testUmmrSecretToCreateName); + } + + private static function randomSecretId(): string + { + return uniqid('php-snippets-'); + } + + private static function createSecret(): Secret + { + $parent = self::$clent->locationName(self::$projectId, self::$locationId); + $secretId = self::randomSecretId(); + $createSecretRequest = (new CreateSecretRequest()) + ->setParent($parent) + ->setSecretId($secretId) + ->setSecret(new Secret()); + + return self::$client->createSecret($createSecretRequest); + } + + private static function addSecretVersion(Secret $secret): SecretVersion + { + $addSecretVersionRequest = (new AddSecretVersionRequest()) + ->setParent($secret->getName()) + ->setPayload(new SecretPayload([ + 'data' => 'my super secret data', + ])); + return self::$client->addSecretVersion($addSecretVersionRequest); + } + + private static function disableSecretVersion(SecretVersion $version): SecretVersion + { + $disableSecretVersionRequest = (new DisableSecretVersionRequest()) + ->setName($version->getName()); + return self::$client->disableSecretVersion($disableSecretVersionRequest); + } + + private static function deleteSecret(string $name) + { + try { + $deleteSecretRequest = (new DeleteSecretRequest()) + ->setName($name); + self::$client->deleteSecret($deleteSecretRequest); + } catch (GaxApiException $e) { + if ($e->getStatus() != 'NOT_FOUND') { + throw $e; + } + } + } + + public function testAccessSecretVersion() + { + $name = self::$client->parseName(self::$testSecretVersion->getName()); + + $output = $this->runFunctionSnippet('access_regional_secret_version', [ + $name['project'], + $name['location'], + $name['secret'], + $name['secret_version'], + ]); + + $this->assertStringContainsString('my super secret data', $output); + } + + public function testAddSecretVersion() + { + $name = self::$client->parseName(self::$testSecretWithVersions->getName()); + + $output = $this->runFunctionSnippet('add_regional_secret_version', [ + $name['project'], + $name['location'], + $name['secret'], + ]); + + $this->assertStringContainsString('Added secret version', $output); + } + + public function testCreateSecret() + { + $name = self::$client->parseName(self::$testSecretToCreateName); + + $output = $this->runFunctionSnippet('create_regional_secret', [ + $name['project'], + $name['location'], + $name['secret'], + ]); + + $this->assertStringContainsString('Created secret', $output); + } + + public function testDeleteSecret() + { + $name = self::$client->parseName(self::$testSecretToDelete->getName()); + + $output = $this->runFunctionSnippet('delete_regional_secret', [ + $name['project'], + $name['location'], + $name['secret'], + ]); + + $this->assertStringContainsString('Deleted secret', $output); + } + + public function testDestroySecretVersion() + { + $name = self::$client->parseName(self::$testSecretVersionToDestroy->getName()); + + $output = $this->runFunctionSnippet('destroy_regional_secret_version', [ + $name['project'], + $name['location'], + $name['secret'], + $name['secret_version'], + ]); + + $this->assertStringContainsString('Destroyed secret version', $output); + } + + public function testDisableSecretVersion() + { + $name = self::$client->parseName(self::$testSecretVersionToDisable->getName()); + + $output = $this->runFunctionSnippet('disable_regional_secret_version', [ + $name['project'], + $name['location'], + $name['secret'], + $name['secret_version'], + ]); + + $this->assertStringContainsString('Disabled secret version', $output); + } + + public function testEnableSecretVersion() + { + $name = self::$client->parseName(self::$testSecretVersionToEnable->getName()); + + $output = $this->runFunctionSnippet('enable_regional_secret_version', [ + $name['project'], + $name['location'], + $name['secret'], + $name['secret_version'], + ]); + + $this->assertStringContainsString('Enabled secret version', $output); + } + + public function testGetSecretVersion() + { + $name = self::$client->parseName(self::$testSecretVersion->getName()); + + $output = $this->runFunctionSnippet('get_regional_secret_version', [ + $name['project'], + $name['location'], + $name['secret'], + $name['secret_version'], + ]); + + $this->assertStringContainsString('Got secret version', $output); + $this->assertStringContainsString('state ENABLED', $output); + } + + public function testGetSecret() + { + $name = self::$client->parseName(self::$testSecret->getName()); + + $output = $this->runFunctionSnippet('get_regional_secret', [ + $name['project'], + $name['location'], + $name['secret'], + ]); + + $this->assertStringContainsString('secret', $output); + } + + public function testIamGrantAccess() + { + $name = self::$client->parseName(self::$testSecret->getName()); + + $output = $this->runFunctionSnippet('regional_iam_grant_access', [ + $name['project'], + $name['location'], + $name['secret'], + self::$iamUser, + ]); + + $this->assertStringContainsString('Updated IAM policy', $output); + } + + public function testIamRevokeAccess() + { + $name = self::$client->parseName(self::$testSecret->getName()); + + $output = $this->runFunctionSnippet('regional_iam_revoke_access', [ + $name['project'], + $name['location'], + $name['secret'], + self::$iamUser, + ]); + + $this->assertStringContainsString('Updated IAM policy', $output); + } + + public function testListSecretVersions() + { + $name = self::$client->parseName(self::$testSecretWithVersions->getName()); + + $output = $this->runFunctionSnippet('list_regional_secret_versions', [ + $name['project'], + $name['location'], + $name['secret'], + ]); + + $this->assertStringContainsString('secret version', $output); + } + + public function testListSecrets() + { + $name = self::$client->parseName(self::$testSecret->getName()); + + $output = $this->runFunctionSnippet('list_regional_secret', [ + $name['project'], + $name['location'], + ]); + + $this->assertStringContainsString('secret', $output); + $this->assertStringContainsString($name['secret'], $output); + } + + public function testUpdateSecret() + { + $name = self::$client->parseName(self::$testSecret->getName()); + + $output = $this->runFunctionSnippet('update_regional_secret', [ + $name['project'], + $name['location'], + $name['secret'], + ]); + + $this->assertStringContainsString('Updated secret', $output); + } + + public function testUpdateSecretWithAlias() + { + $name = self::$client->parseName(self::$testSecretWithVersions->getName()); + + $output = $this->runFunctionSnippet('update_regional_secret_with_alias', [ + $name['project'], + $name['location'], + $name['secret'], + ]); + + $this->assertStringContainsString('Updated secret', $output); + } +} From 9fb4256d0ad4f6f4746c2a49ecb545da7a499eb2 Mon Sep 17 00:00:00 2001 From: Kapish Date: Thu, 29 Aug 2024 07:06:24 +0000 Subject: [PATCH 2/8] Fix lint issues --- secretmanager/src/list_regional_secrets.php | 2 +- secretmanager/test/regionalsecretmanagerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/secretmanager/src/list_regional_secrets.php b/secretmanager/src/list_regional_secrets.php index 85303665ee..1d5636272c 100644 --- a/secretmanager/src/list_regional_secrets.php +++ b/secretmanager/src/list_regional_secrets.php @@ -34,7 +34,7 @@ * @param string $projectId Your Google Cloud Project ID (e.g. 'my-project') * @param string $locationId Your secret Location (e.g. "us-central1") */ -function list_regional_secret(string $projectId, string $locationId,): void +function list_regional_secret(string $projectId, string $locationId): void { # Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; diff --git a/secretmanager/test/regionalsecretmanagerTest.php b/secretmanager/test/regionalsecretmanagerTest.php index 6a19d2ce16..694072a702 100644 --- a/secretmanager/test/regionalsecretmanagerTest.php +++ b/secretmanager/test/regionalsecretmanagerTest.php @@ -51,7 +51,7 @@ class regionalsecretmanagerTest extends TestCase public static function setUpBeforeClass(): void { - $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; + $options = ['apiEndpoint' => "secretmanager." . self::$locationId . ".rep.googleapis.com" ]; self::$client = new SecretManagerServiceClient($options); self::$testSecret = self::createSecret(); From a641ae81f631839c0a16d5d0f867ba8dc8e337df Mon Sep 17 00:00:00 2001 From: Kapish Date: Thu, 29 Aug 2024 07:20:03 +0000 Subject: [PATCH 3/8] Fix typo --- secretmanager/test/regionalsecretmanagerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/secretmanager/test/regionalsecretmanagerTest.php b/secretmanager/test/regionalsecretmanagerTest.php index 694072a702..168df9393c 100644 --- a/secretmanager/test/regionalsecretmanagerTest.php +++ b/secretmanager/test/regionalsecretmanagerTest.php @@ -51,7 +51,7 @@ class regionalsecretmanagerTest extends TestCase public static function setUpBeforeClass(): void { - $options = ['apiEndpoint' => "secretmanager." . self::$locationId . ".rep.googleapis.com" ]; + $options = ['apiEndpoint' => 'secretmanager.' . self::$locationId . '.rep.googleapis.com' ]; self::$client = new SecretManagerServiceClient($options); self::$testSecret = self::createSecret(); @@ -83,7 +83,7 @@ private static function randomSecretId(): string private static function createSecret(): Secret { - $parent = self::$clent->locationName(self::$projectId, self::$locationId); + $parent = self::$client->locationName(self::$projectId, self::$locationId); $secretId = self::randomSecretId(); $createSecretRequest = (new CreateSecretRequest()) ->setParent($parent) From 60716e85a56027f7e3bb3a53f14e7f4368200563 Mon Sep 17 00:00:00 2001 From: Kapish Date: Thu, 29 Aug 2024 08:27:52 +0000 Subject: [PATCH 4/8] Fix helper paths --- secretmanager/src/access_regional_secret_version.php | 2 +- secretmanager/src/add_regional_secret_version.php | 2 +- secretmanager/src/create_regional_secret.php | 2 +- secretmanager/test/regionalsecretmanagerTest.php | 9 ++++----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/secretmanager/src/access_regional_secret_version.php b/secretmanager/src/access_regional_secret_version.php index f9e5d6323d..fc906501d8 100644 --- a/secretmanager/src/access_regional_secret_version.php +++ b/secretmanager/src/access_regional_secret_version.php @@ -63,5 +63,5 @@ function access_regional_secret_version(string $projectId, string $locationId, s // [END secretmanager_access_regional_secret_version] // The following 2 lines are only needed to execute the samples on the CLI -require_once __DIR__ . '/../../../testing/sample_helpers.php'; +require_once __DIR__ . '/../../testing/sample_helpers.php'; \Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/add_regional_secret_version.php b/secretmanager/src/add_regional_secret_version.php index 465dc388ac..cf4425d019 100644 --- a/secretmanager/src/add_regional_secret_version.php +++ b/secretmanager/src/add_regional_secret_version.php @@ -62,5 +62,5 @@ function add_regional_secret_version(string $projectId, string $locationId, stri // [END secretmanager_add_regional_secret_version] // The following 2 lines are only needed to execute the samples on the CLI -require_once __DIR__ . '/../../../testing/sample_helpers.php'; +require_once __DIR__ . '/../../testing/sample_helpers.php'; \Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/src/create_regional_secret.php b/secretmanager/src/create_regional_secret.php index 68f98b9a77..80b9ca372a 100644 --- a/secretmanager/src/create_regional_secret.php +++ b/secretmanager/src/create_regional_secret.php @@ -61,5 +61,5 @@ function create_regional_secret(string $projectId, string $locationId, string $s // [END secretmanager_create_regional_secret] // The following 2 lines are only needed to execute the samples on the CLI -require_once __DIR__ . '/../../../testing/sample_helpers.php'; +require_once __DIR__ . '/../../testing/sample_helpers.php'; \Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/secretmanager/test/regionalsecretmanagerTest.php b/secretmanager/test/regionalsecretmanagerTest.php index 168df9393c..11a6b47681 100644 --- a/secretmanager/test/regionalsecretmanagerTest.php +++ b/secretmanager/test/regionalsecretmanagerTest.php @@ -40,7 +40,6 @@ class regionalsecretmanagerTest extends TestCase private static $testSecretToDelete; private static $testSecretWithVersions; private static $testSecretToCreateName; - private static $testUmmrSecretToCreateName; private static $testSecretVersion; private static $testSecretVersionToDestroy; private static $testSecretVersionToDisable; @@ -57,9 +56,7 @@ public static function setUpBeforeClass(): void self::$testSecret = self::createSecret(); self::$testSecretToDelete = self::createSecret(); self::$testSecretWithVersions = self::createSecret(); - self::$testSecretToCreateName = self::$client->secretName(self::$projectId, self::randomSecretId()); - self::$testUmmrSecretToCreateName = self::$client->secretName(self::$projectId, self::randomSecretId()); - + self::$testSecretToCreateName = self::$client->projectLocationSecretName(self::$projectId, self::$locationId, self::randomSecretId()); self::$testSecretVersion = self::addSecretVersion(self::$testSecretWithVersions); self::$testSecretVersionToDestroy = self::addSecretVersion(self::$testSecretWithVersions); self::$testSecretVersionToDisable = self::addSecretVersion(self::$testSecretWithVersions); @@ -69,11 +66,13 @@ public static function setUpBeforeClass(): void public static function tearDownAfterClass(): void { + $options = ['apiEndpoint' => 'secretmanager.' . self::$locationId . '.rep.googleapis.com' ]; + self::$client = new SecretManagerServiceClient($options); + self::deleteSecret(self::$testSecret->getName()); self::deleteSecret(self::$testSecretToDelete->getName()); self::deleteSecret(self::$testSecretWithVersions->getName()); self::deleteSecret(self::$testSecretToCreateName); - self::deleteSecret(self::$testUmmrSecretToCreateName); } private static function randomSecretId(): string From aba7bc27d6a8f03bf19a2566ea685923812407e8 Mon Sep 17 00:00:00 2001 From: Kapish Date: Thu, 29 Aug 2024 08:35:32 +0000 Subject: [PATCH 5/8] Fix function name --- secretmanager/test/regionalsecretmanagerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/secretmanager/test/regionalsecretmanagerTest.php b/secretmanager/test/regionalsecretmanagerTest.php index 11a6b47681..80c6946200 100644 --- a/secretmanager/test/regionalsecretmanagerTest.php +++ b/secretmanager/test/regionalsecretmanagerTest.php @@ -68,7 +68,7 @@ public static function tearDownAfterClass(): void { $options = ['apiEndpoint' => 'secretmanager.' . self::$locationId . '.rep.googleapis.com' ]; self::$client = new SecretManagerServiceClient($options); - + self::deleteSecret(self::$testSecret->getName()); self::deleteSecret(self::$testSecretToDelete->getName()); self::deleteSecret(self::$testSecretWithVersions->getName()); @@ -290,7 +290,7 @@ public function testListSecrets() { $name = self::$client->parseName(self::$testSecret->getName()); - $output = $this->runFunctionSnippet('list_regional_secret', [ + $output = $this->runFunctionSnippet('list_regional_secrets', [ $name['project'], $name['location'], ]); From 142baef97af1e252d840f6bbc6c0f5355637a91b Mon Sep 17 00:00:00 2001 From: Kapish Date: Thu, 29 Aug 2024 08:40:50 +0000 Subject: [PATCH 6/8] update function name to match filename --- secretmanager/src/list_regional_secrets.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/secretmanager/src/list_regional_secrets.php b/secretmanager/src/list_regional_secrets.php index 1d5636272c..11246e83f6 100644 --- a/secretmanager/src/list_regional_secrets.php +++ b/secretmanager/src/list_regional_secrets.php @@ -25,7 +25,7 @@ namespace Google\Cloud\Samples\SecretManager; -// [START secretmanager_list_regional_secret] +// [START secretmanager_list_regional_secrets] // Import the Secret Manager client library. use Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient; use Google\Cloud\SecretManager\V1\ListSecretsRequest; @@ -34,7 +34,7 @@ * @param string $projectId Your Google Cloud Project ID (e.g. 'my-project') * @param string $locationId Your secret Location (e.g. "us-central1") */ -function list_regional_secret(string $projectId, string $locationId): void +function list_regional_secrets(string $projectId, string $locationId): void { # Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; @@ -53,7 +53,7 @@ function list_regional_secret(string $projectId, string $locationId): void printf('Found secret %s', $secret->getName()); } } -// [END secretmanager_list_regional_secret] +// [END secretmanager_list_regional_secrets] // The following 2 lines are only needed to execute the samples on the CLI require_once __DIR__ . '/../../testing/sample_helpers.php'; From f2fe49df6026430628ec7ba2eb9e050e7f8005da Mon Sep 17 00:00:00 2001 From: Kapish Date: Wed, 4 Dec 2024 18:26:39 +0000 Subject: [PATCH 7/8] fix comments --- secretmanager/src/access_regional_secret_version.php | 2 +- secretmanager/src/add_regional_secret_version.php | 2 +- secretmanager/src/create_regional_secret.php | 2 +- secretmanager/src/delete_regional_secret.php | 2 +- secretmanager/src/destroy_regional_secret_version.php | 2 +- secretmanager/src/disable_regional_secret_version.php | 2 +- secretmanager/src/enable_regional_secret_version.php | 2 +- secretmanager/src/get_regional_secret.php | 2 +- secretmanager/src/get_regional_secret_version.php | 2 +- secretmanager/src/list_regional_secret_versions.php | 2 +- secretmanager/src/list_regional_secrets.php | 2 +- secretmanager/src/regional_iam_grant_access.php | 2 +- secretmanager/src/regional_iam_revoke_access.php | 2 +- secretmanager/src/update_regional_secret.php | 2 +- secretmanager/src/update_regional_secret_with_alias.php | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/secretmanager/src/access_regional_secret_version.php b/secretmanager/src/access_regional_secret_version.php index fc906501d8..e8a3521f38 100644 --- a/secretmanager/src/access_regional_secret_version.php +++ b/secretmanager/src/access_regional_secret_version.php @@ -38,7 +38,7 @@ */ function access_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/add_regional_secret_version.php b/secretmanager/src/add_regional_secret_version.php index cf4425d019..54edf72fc8 100644 --- a/secretmanager/src/add_regional_secret_version.php +++ b/secretmanager/src/add_regional_secret_version.php @@ -38,7 +38,7 @@ */ function add_regional_secret_version(string $projectId, string $locationId, string $secretId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/create_regional_secret.php b/secretmanager/src/create_regional_secret.php index 80b9ca372a..4506673542 100644 --- a/secretmanager/src/create_regional_secret.php +++ b/secretmanager/src/create_regional_secret.php @@ -38,7 +38,7 @@ */ function create_regional_secret(string $projectId, string $locationId, string $secretId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/delete_regional_secret.php b/secretmanager/src/delete_regional_secret.php index 60d503c37e..47bbcfdfa5 100644 --- a/secretmanager/src/delete_regional_secret.php +++ b/secretmanager/src/delete_regional_secret.php @@ -37,7 +37,7 @@ */ function delete_regional_secret(string $projectId, string $locationId, string $secretId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/destroy_regional_secret_version.php b/secretmanager/src/destroy_regional_secret_version.php index e8f0cab7d2..4c97ba63e2 100644 --- a/secretmanager/src/destroy_regional_secret_version.php +++ b/secretmanager/src/destroy_regional_secret_version.php @@ -38,7 +38,7 @@ */ function destroy_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/disable_regional_secret_version.php b/secretmanager/src/disable_regional_secret_version.php index a2cbc56d0a..212aa8832d 100644 --- a/secretmanager/src/disable_regional_secret_version.php +++ b/secretmanager/src/disable_regional_secret_version.php @@ -38,7 +38,7 @@ */ function disable_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/enable_regional_secret_version.php b/secretmanager/src/enable_regional_secret_version.php index 82a7e902a3..9f6740f6cb 100644 --- a/secretmanager/src/enable_regional_secret_version.php +++ b/secretmanager/src/enable_regional_secret_version.php @@ -38,7 +38,7 @@ */ function enable_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/get_regional_secret.php b/secretmanager/src/get_regional_secret.php index 3c5b6e49e0..ad0014ad11 100644 --- a/secretmanager/src/get_regional_secret.php +++ b/secretmanager/src/get_regional_secret.php @@ -37,7 +37,7 @@ */ function get_regional_secret(string $projectId, string $locationId, string $secretId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/get_regional_secret_version.php b/secretmanager/src/get_regional_secret_version.php index 6f785253d6..d2ec17bf66 100644 --- a/secretmanager/src/get_regional_secret_version.php +++ b/secretmanager/src/get_regional_secret_version.php @@ -39,7 +39,7 @@ */ function get_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/list_regional_secret_versions.php b/secretmanager/src/list_regional_secret_versions.php index 395270c14a..3e403ede99 100644 --- a/secretmanager/src/list_regional_secret_versions.php +++ b/secretmanager/src/list_regional_secret_versions.php @@ -37,7 +37,7 @@ */ function list_regional_secret_versions(string $projectId, string $locationId, string $secretId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/list_regional_secrets.php b/secretmanager/src/list_regional_secrets.php index 11246e83f6..b81d9342e1 100644 --- a/secretmanager/src/list_regional_secrets.php +++ b/secretmanager/src/list_regional_secrets.php @@ -36,7 +36,7 @@ */ function list_regional_secrets(string $projectId, string $locationId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/regional_iam_grant_access.php b/secretmanager/src/regional_iam_grant_access.php index b649b2b2a1..7142c4cac8 100644 --- a/secretmanager/src/regional_iam_grant_access.php +++ b/secretmanager/src/regional_iam_grant_access.php @@ -42,7 +42,7 @@ */ function regional_iam_grant_access(string $projectId, string $locationId, string $secretId, string $member): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/regional_iam_revoke_access.php b/secretmanager/src/regional_iam_revoke_access.php index 06caf701d3..8cfffc9da3 100644 --- a/secretmanager/src/regional_iam_revoke_access.php +++ b/secretmanager/src/regional_iam_revoke_access.php @@ -39,7 +39,7 @@ */ function regional_iam_revoke_access(string $projectId, string $locationId, string $secretId, string $member): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/update_regional_secret.php b/secretmanager/src/update_regional_secret.php index fe5cda1fe9..1e605261a3 100644 --- a/secretmanager/src/update_regional_secret.php +++ b/secretmanager/src/update_regional_secret.php @@ -39,7 +39,7 @@ */ function update_regional_secret(string $projectId, string $locationId, string $secretId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. diff --git a/secretmanager/src/update_regional_secret_with_alias.php b/secretmanager/src/update_regional_secret_with_alias.php index aaa43cbc2f..b86f0185fb 100644 --- a/secretmanager/src/update_regional_secret_with_alias.php +++ b/secretmanager/src/update_regional_secret_with_alias.php @@ -39,7 +39,7 @@ */ function update_regional_secret_with_alias(string $projectId, string $locationId, string $secretId): void { - # Specify regional endpoint. + // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; // Create the Secret Manager client. From c9837c735850dd8854b9ea791e301af030ce1bf0 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 12 Dec 2024 07:39:26 -0800 Subject: [PATCH 8/8] format cs --- secretmanager/src/access_regional_secret_version.php | 8 ++++++-- .../src/create_secret_with_user_managed_replication.php | 7 +++++-- secretmanager/src/destroy_regional_secret_version.php | 8 ++++++-- secretmanager/src/disable_regional_secret_version.php | 8 ++++++-- secretmanager/src/enable_regional_secret_version.php | 8 ++++++-- secretmanager/src/get_regional_secret_version.php | 8 ++++++-- 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/secretmanager/src/access_regional_secret_version.php b/secretmanager/src/access_regional_secret_version.php index e8a3521f38..93e8a1d037 100644 --- a/secretmanager/src/access_regional_secret_version.php +++ b/secretmanager/src/access_regional_secret_version.php @@ -36,8 +36,12 @@ * @param string $secretId Your secret ID (e.g. 'my-secret') * @param string $versionId Your version ID (e.g. 'latest' or '5'); */ -function access_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void -{ +function access_regional_secret_version( + string $projectId, + string $locationId, + string $secretId, + string $versionId +): void { // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; diff --git a/secretmanager/src/create_secret_with_user_managed_replication.php b/secretmanager/src/create_secret_with_user_managed_replication.php index 9985caccc8..bda990f97d 100644 --- a/secretmanager/src/create_secret_with_user_managed_replication.php +++ b/secretmanager/src/create_secret_with_user_managed_replication.php @@ -38,8 +38,11 @@ * @param string $secretId Your secret ID (e.g. 'my-secret') * @param array $locations Replication locations (e.g. array('us-east1', 'us-east4')) */ -function create_secret_with_user_managed_replication(string $projectId, string $secretId, array $locations): void -{ +function create_secret_with_user_managed_replication( + string $projectId, + string $secretId, + array $locations +): void { // Create the Secret Manager client. $client = new SecretManagerServiceClient(); diff --git a/secretmanager/src/destroy_regional_secret_version.php b/secretmanager/src/destroy_regional_secret_version.php index 4c97ba63e2..7fcdc9bd3e 100644 --- a/secretmanager/src/destroy_regional_secret_version.php +++ b/secretmanager/src/destroy_regional_secret_version.php @@ -36,8 +36,12 @@ * @param string $secretId Your secret ID (e.g. 'my-secret') * @param string $versionId Your version ID (e.g. 'latest' or '5'); */ -function destroy_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void -{ +function destroy_regional_secret_version( + string $projectId, + string $locationId, + string $secretId, + string $versionId +): void { // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; diff --git a/secretmanager/src/disable_regional_secret_version.php b/secretmanager/src/disable_regional_secret_version.php index 212aa8832d..a34f0d7a9d 100644 --- a/secretmanager/src/disable_regional_secret_version.php +++ b/secretmanager/src/disable_regional_secret_version.php @@ -36,8 +36,12 @@ * @param string $secretId Your secret ID (e.g. 'my-secret') * @param string $versionId Your version ID (e.g. 'latest' or '5'); */ -function disable_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void -{ +function disable_regional_secret_version( + string $projectId, + string $locationId, + string $secretId, + string $versionId +): void { // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; diff --git a/secretmanager/src/enable_regional_secret_version.php b/secretmanager/src/enable_regional_secret_version.php index 9f6740f6cb..d237d12805 100644 --- a/secretmanager/src/enable_regional_secret_version.php +++ b/secretmanager/src/enable_regional_secret_version.php @@ -36,8 +36,12 @@ * @param string $secretId Your secret ID (e.g. 'my-secret') * @param string $versionId Your version ID (e.g. 'latest' or '5'); */ -function enable_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void -{ +function enable_regional_secret_version( + string $projectId, + string $locationId, + string $secretId, + string $versionId +): void { // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"]; diff --git a/secretmanager/src/get_regional_secret_version.php b/secretmanager/src/get_regional_secret_version.php index d2ec17bf66..0e50e2410f 100644 --- a/secretmanager/src/get_regional_secret_version.php +++ b/secretmanager/src/get_regional_secret_version.php @@ -37,8 +37,12 @@ * @param string $secretId Your secret ID (e.g. 'my-secret') * @param string $versionId Your version ID (e.g. 'latest' or '5'); */ -function get_regional_secret_version(string $projectId, string $locationId, string $secretId, string $versionId): void -{ +function get_regional_secret_version( + string $projectId, + string $locationId, + string $secretId, + string $versionId +): void { // Specify regional endpoint. $options = ['apiEndpoint' => "secretmanager.$locationId.rep.googleapis.com"];