Class SecretVersion


  • public class SecretVersion
    extends Object

    Provides a Secret Version class. The Secret Version is used to specify a particular secret version stored with the Secret API. To obtain the latest secret version value use the Secret.latest().access() methods.

    See Also:
    Secrets, Secret, SecretValue
    • Method Detail

      • getSecret

        public Secret getSecret()
        Return the version secret.
        Returns:
        the version secret
      • getVersion

        public String getVersion()
        Return the secret version.
        Returns:
        the secret version
      • access

        public SecretValue access()

        Return the version's secret value if found, or throws an exception otherwise.

        
         String keyVersion = ...
        
         SecretValue secretValue = Secrets.secret("encryption.key")
             .version(keyVersion)
             .access();
        
         byte[] keyData = secretValue.get();
         
        Returns:
        the version's secret value if found, or throws an exception otherwise
        Throws:
        io.grpc.StatusRuntimeException - if the secret value was not found
      • toString

        public String toString()
        Return the string representation of this object.
        Overrides:
        toString in class Object
        Returns:
        the string representation of this object