public SecretVersion EnableSecretVersion( 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.EnableSecretVersion(secretVersionName); return(version); }
// [END secretmanager_disable_secret_version] // [START secretmanager_enable_secret_version] /// <summary> /// Enable 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>1 /// Enable an existing secret version. /// <code>EnableSecretVersion("my-project", "my-secret", "5")</code> /// </example> public static void EnableSecretVersion(string projectId, string secretId, string secretVersion) { SecretManagerServiceClient client = SecretManagerServiceClient.Create(); // Create the request. var request = new EnableSecretVersionRequest { SecretVersionName = new SecretVersionName(projectId, secretId, secretVersion), }; // Enable the secret version. var version = client.EnableSecretVersion(request); Console.WriteLine($"Enabled secret version {version.Name}"); }