public void DeleteSecret( string projectId = "my-project", string secretId = "my-secret") { // Create the client. SecretManagerServiceClient client = SecretManagerServiceClient.Create(); // Build the resource name. SecretName secretName = new SecretName(projectId, secretId); // Delete the secret. client.DeleteSecret(secretName); }
private void DeleteSecret(SecretName name) { SecretManagerServiceClient client = SecretManagerServiceClient.Create(); try { client.DeleteSecret(name); } catch (Grpc.Core.RpcException e) when(e.StatusCode == Grpc.Core.StatusCode.NotFound) { // Ignore error - secret was already deleted } }
private void DeleteSecret(SecretName name) { try { _client.DeleteSecret(new DeleteSecretRequest { SecretName = name }); } catch (Grpc.Core.RpcException e) when(e.StatusCode == Grpc.Core.StatusCode.NotFound) { // Ignore error - secret was already deleted } }
// [END secretmanager_create_secret] // [START secretmanager_delete_secret] /// <summary> /// Delete an existing secret with the given name. /// </summary> /// <param name="projectId">ID of the project where the secret resides.</param> /// <param name="secretId">ID of the secret.</param> /// <example> /// Delete a secret. /// <code>DeleteSecret("my-project", "my-secret")</code> /// </example> public static void DeleteSecret(string projectId, string secretId) { SecretManagerServiceClient client = SecretManagerServiceClient.Create(); // Create the request. var request = new DeleteSecretRequest { SecretName = new SecretName(projectId, secretId), }; // Delete the secret. client.DeleteSecret(request); Console.WriteLine($"Deleted secret {secretId}"); }
public void TestRun() { string ts = $"{DateTime.Now.ToString("yyyyMMddHHmmssfff")}"; string secretId = $"csharp-quickstart-{ts}-1"; // Run quickstart var output = _quickStart.Run(s_projectId, secretId); // Verify output Assert.Equal(0, output.ExitCode); Assert.Contains($"Plaintext: my super secret data", output.Stdout); // Delete the secret created by quickstart SecretManagerServiceClient client = SecretManagerServiceClient.Create(); client.DeleteSecret(new DeleteSecretRequest { SecretName = new SecretName(s_projectId, secretId), }); }