Exemple #1
0
 private void DisableSecretVersion(SecretVersion version)
 {
     _client.DisableSecretVersion(new DisableSecretVersionRequest
     {
         SecretVersionName = version.SecretVersionName,
     });
 }
    public SecretVersion DisableSecretVersion(
        string projectId = "my-project", string secretId = "my-secret", string secretVersionId = "123")
    {
        // Create the client.
        SecretManagerServiceClient client = SecretManagerServiceClient.Create();

        // Build the resource name.
        SecretVersionName secretVersionName = new SecretVersionName(projectId, secretId, secretVersionId);

        // Call the API.
        SecretVersion version = client.DisableSecretVersion(secretVersionName);

        return(version);
    }
        // [END secretmanager_destroy_secret_version]

        // [START secretmanager_disable_secret_version]
        /// <summary>
        /// Disable an existing secret version.
        /// </summary>
        /// <param name="projectId">ID of the project where the secret resides.</param>
        /// <param name="secretId">ID of the secret.</param>
        /// <param name="secretVersion">Version of the secret.</param>
        /// <example>
        /// Disable an existing secret version.
        /// <code>DisableSecretVersion("my-project", "my-secret", "5")</code>
        /// </example>
        public static void DisableSecretVersion(string projectId, string secretId, string secretVersion)
        {
            SecretManagerServiceClient client = SecretManagerServiceClient.Create();

            // Create the request.
            var request = new DisableSecretVersionRequest
            {
                SecretVersionName = new SecretVersionName(projectId, secretId, secretVersion),
            };

            // Disable the secret version.
            var version = client.DisableSecretVersion(request);

            Console.WriteLine($"Disabled secret version {version.Name}");
        }
Exemple #4
0
    private void DisableSecretVersion(SecretVersion version)
    {
        SecretManagerServiceClient client = SecretManagerServiceClient.Create();

        client.DisableSecretVersion(version.SecretVersionName);
    }