public void TestCreateSecret()
        {
            var name   = secretsFixture.SecretToCreateName;
            var output = Run("create", name.ProjectId, name.SecretId);

            Assert.Contains("Created secret", output.Stdout);

            var secret = s_client.GetSecret(new GetSecretRequest
            {
                SecretName = name
            });

            Assert.Equal(name.SecretId, secret.SecretName.SecretId);
        }
    public void DeletesSecrets()
    {
        SecretName secretName = _fixture.SecretToDelete.SecretName;

        _sample.DeleteSecret(projectId: secretName.ProjectId, secretId: secretName.SecretId);

        SecretManagerServiceClient client = SecretManagerServiceClient.Create();

        Assert.Throws <Grpc.Core.RpcException>(() => client.GetSecret(secretName));
    }
Ejemplo n.º 3
0
    public Secret GetSecret(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);

        // Call the API.
        Secret secret = client.GetSecret(secretName);

        return(secret);
    }
Ejemplo n.º 4
0
        // [END secretmanager_get_secret_version]

        // [START secretmanager_get_secret]
        /// <summary>
        /// Get an existing secret.
        /// </summary>
        /// <param name="projectId">ID of the project where the secret resides.</param>
        /// <param name="secretId">ID of the secret.</param>
        /// <example>
        /// Get an existing secret.
        /// <code>GetSecret("my-project", "my-secret")</code>
        /// </example>
        public static void GetSecret(string projectId, string secretId)
        {
            SecretManagerServiceClient client = SecretManagerServiceClient.Create();

            // Create the request.
            var request = new GetSecretRequest
            {
                SecretName = new SecretName(projectId, secretId),
            };

            // Get the secret.
            var secret = client.GetSecret(request);

            Console.WriteLine($"Secret {secret.Name}, replication {secret.Replication.ReplicationCase}");
        }