class Cipherpipe::Vault::API

Public Instance Methods

read(path, options = {}) click to toggle source
# File lib/cipherpipe/vault/api.rb, line 2
def read(path, options = {})
  headers = extract_headers! options
  json    = client.get("/v1/secret/data/#{encode_path(path)}", {}, headers)

  ::Vault::Secret.decode json[:data]
rescue ::Vault::HTTPError => error
  return nil if error.code == 404
  raise error
end
write(path, data = {}, options = {}) click to toggle source
# File lib/cipherpipe/vault/api.rb, line 12
def write(path, data = {}, options = {})
  headers = extract_headers! options
  json    = Vault.logical.client.post(
    "/v1/secret/data/#{encode_path path}",
    JSON.fast_generate(:data => data),
    headers
  )

  json.nil? ? true : ::Vault::Secret.decode(json)
end