Class: Vault::Secret

Inherits:
Response show all
Defined in:
lib/vault/api/secret.rb

Overview

Secret is a representation of a secret from Vault. Almost all data returned from Vault is represented as a secret.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Response

#==, decode, #initialize, #to_h

Constructor Details

This class inherits a constructor from Vault::Response

Instance Attribute Details

#authSecretAuth? (readonly)

Authentication information for this secret, if any. Most secrets will contain this field, but it may also be ‘nil`. When authenticating to Vault, the resulting Vault token will be included in this embedded field.

Examples:

Authenticating to Vault

secret = Vault.auth.userpass("username", "password")
secret.auth.client_token #=> "fdb29070-6379-70c9-ca3a-46152fb66de1"

Returns:



23
# File 'lib/vault/api/secret.rb', line 23

field :auth, load: ->(v) { SecretAuth.decode(v) }

#dataHash<Symbol, Object> (readonly)

Arbitrary data returned by the secret. The keys returned are dependent upon the request made. For more information on the names of the keys that may be returned, please see the Vault documentation.

Examples:

Reading data

secret = Vault.auth.token("abcd1234")
secret.data[:id] #=> "abcd1234"
secret.data[:ttl] #=> 0

Returns:

  • (Hash<Symbol, Object>)


36
# File 'lib/vault/api/secret.rb', line 36

field :data, freeze: true

#lease_durationFixnum (readonly)

The number of seconds this lease is valid. If this number is 0 or nil, the secret does not expire.

Examples:

Getting lease duration

secret = Vault.logical.read("secret/foo")
secret.lease_duration #=> 2592000 # 30 days

Returns:

  • (Fixnum)


59
# File 'lib/vault/api/secret.rb', line 59

field :lease_duration

#lease_idString (readonly)

Unique ID for the lease associated with this secret. The ‘lease_id` is a path and UUID that uniquely represents the secret. This may be used for renewing and revoking the secret, if permitted.

Examples:

Getting lease ID

secret = Vault.logical.read("postgresql/creds/readonly")
secret.lease_id #=> "postgresql/readonly/fdb29070-6379-70c9-ca3a-46152fb66de1"

Returns:

  • (String)


71
# File 'lib/vault/api/secret.rb', line 71

field :lease_id

#metadataHash<Symbol, Object> (readonly)

Read-only metadata information related to the secret.

Examples:

Reading metadata

secret = Vault.logical(:versioned).read("secret", "foo")
secret.[:created_time] #=> "2018-12-08T04:22:54.168065Z"
secret.[:version]      #=> 1
secret.[:destroyed]    #=> false

Returns:

  • (Hash<Symbol, Object>)


48
# File 'lib/vault/api/secret.rb', line 48

field :metadata, freeze: true

#warningsArray<String>? (readonly)

List of warnings returned by the Vault server. These are returned by the Vault server and may include deprecation information, new APIs, or request using the API differently in the future.

Examples:

Display warnings

result = Vault.logical.read("secret/foo")
result.warnings #=> ["This path has been deprecated"]

Returns:

  • (Array<String>, nil)


93
# File 'lib/vault/api/secret.rb', line 93

field :warnings, freeze: true

#wrap_infoWrapInfo? (readonly)

Wrapped information sent with the request (only present in Vault 0.6+).

Returns:



98
# File 'lib/vault/api/secret.rb', line 98

field :wrap_info, load: ->(v) { WrapInfo.decode(v) }

Instance Method Details

#renewable([r]) ⇒ Boolean

Returns whether this lease is renewable.

Examples:

Checking if a lease is renewable

secret = Vault.logical.read("secret/foo")
secret.renewable? #=> false

Returns:

  • (Boolean)


81
# File 'lib/vault/api/secret.rb', line 81

field :renewable, as: :renewable?