Class: Vault::Logical
Instance Attribute Summary
Attributes inherited from Request
Instance Method Summary collapse
-
#delete(path) ⇒ true
Delete the secret at the given path.
-
#read(path) ⇒ Secret?
Read the secret at the given path.
-
#write(path, data = {}) ⇒ Secret
Write the secret at the given path with the given data.
Methods inherited from Request
Constructor Details
This class inherits a constructor from Vault::Request
Instance Method Details
#delete(path) ⇒ true
Delete the secret at the given path. If the secret does not exist, vault will still return true.
65 66 67 68 |
# File 'lib/vault/api/logical.rb', line 65 def delete(path) client.delete("/v1/#{path}") return true end |
#read(path) ⇒ Secret?
Read the secret at the given path. If the secret does not exist, nil
will be returned.
26 27 28 29 30 31 32 |
# File 'lib/vault/api/logical.rb', line 26 def read(path) json = client.get("/v1/#{path}") return Secret.decode(json) rescue HTTPError => e return nil if e.code == 404 raise end |
#write(path, data = {}) ⇒ Secret
Write the secret at the given path with the given data. Note that the data must be a Hash!
46 47 48 49 50 51 52 53 |
# File 'lib/vault/api/logical.rb', line 46 def write(path, data = {}) json = client.put("/v1/#{path}", JSON.fast_generate(data)) if json.nil? return true else return Secret.decode(json) end end |