Ptolemy v0.2.0 Ptolemy.Engines.KV View Source

Ptolemy.Engines.KV provides a public facing API for CRUD operations for the Vault KV2 engine.

Link to this section Summary

Functions

Creates a secret according to the path specified in the :kv_engine specification

Creates a secret according to the path specified in the ":kv_engine" specification, errors out if an error occurs

Deletes a secific version of a secret via the :kv_engine configuration

Deletes a secific version of a secret via the :kv_engine configuration, errors out if an errors occurs

Destroys a secific version of a secret via the :kv_engine configuration

Destroys a secific version of a secret via the :kv_engine configuration, errors out if an error occurs

Creates a new secret via a KV engine at the specified path

Deletes a secific version of a secret at a specified path

Destroys a specific version of secret at a specified path

Fetches all of a given secret's key and values from a KV engine via the specified path

Updates an already existing secret via the specified path

Fetches all of a secret's keys and value via the :kv_engine configuration

Fetches all of a secret's keys and value via the :kv_engine configuration, errors out if an error occurs

Updates an already existing secret via the :kv_engine configuration

Updates an already existing secret via the :kv_engine configuration, errors out if an error occurs

Link to this section Functions

Link to this function

create(server_name, engine_name, secret, payload, cas \\ nil) View Source
create(atom(), atom(), atom(), map(), integer() | nil) ::
  {:ok, String.t()} | {:error, String.t()}

Creates a secret according to the path specified in the :kv_engine specification.

Example

iex(2)> Ptolemy.Engines.KV.create(:production, :engine1, :ptolemy, %{test: "i was created from config"})
{:ok, "KV secret created"}
Link to this function

create!(server_name, engine_name, secret, payload, cas \\ nil) View Source
create!(atom(), atom(), atom(), map(), integer() | nil) :: :ok | no_return()

Creates a secret according to the path specified in the ":kv_engine" specification, errors out if an error occurs.

Link to this function

delete(server_name, engine_name, secret, vers, destroy \\ false) View Source
delete(atom(), atom(), atom(), [integer(), ...], boolean()) ::
  {:ok, String.t()} | {:error, String.t()}

Deletes a secific version of a secret via the :kv_engine configuration.

Specifying false under the destroy paramter will "delete" the secret (secret will be sent to recyling bin), sepcifying true will permanently destroy the secret.

iex(2)> Ptolemy.Engines.KV.delete(:production, :engine1, :ptolemy, [1,2], false)
{:ok, "KV secret deleted"}
Link to this function

delete!(server_name, engine_name, secret, vers, destroy \\ false) View Source
delete!(atom(), atom(), atom(), [integer(), ...], boolean()) ::
  :ok | no_return()

Deletes a secific version of a secret via the :kv_engine configuration, errors out if an errors occurs.

Link to this function

destroy(server_name, engine_name, secret, vers) View Source
destroy(atom(), atom(), String.t(), [integer(), ...]) ::
  {:ok, String.t()} | {:error, String.t()}

Destroys a secific version of a secret via the :kv_engine configuration.

iex(2)> Ptolemy.Engines.KV.destroy(:production, :engine1, :ptolemy, [1,2])
{:ok, "KV secret destroyed"}
Link to this function

destroy!(server_name, engine_name, secret, vers) View Source
destroy!(atom(), atom(), String.t(), [integer(), ...]) :: :ok | no_return()

Destroys a secific version of a secret via the :kv_engine configuration, errors out if an error occurs.

Link to this function

path_create(server_name, secret, payload, cas \\ nil) View Source
path_create(atom(), String.t(), map(), integer() | nil) ::
  {:ok, String.t()} | {:error, String.t()}

Creates a new secret via a KV engine at the specified path.

Example

iex(2)> Ptolemy.Engines.KV.path_create(:production, "secret/data/new", %{test: "i am created from path"})
{:ok, "KV secret created"}
Link to this function

path_delete(server_name, secret, vers) View Source
path_delete(atom(), String.t(), [integer(), ...]) ::
  {:ok, String.t()} | {:error, String.t()}

Deletes a secific version of a secret at a specified path.

iex(2)> Ptolemy.Engines.KV.path_delete(:production, "secret/delete/ptolemy", [1,2])
{:ok, "KV secret deleted"}
Link to this function

path_destroy(server_name, secret, vers) View Source
path_destroy(atom(), String.t(), [integer(), ...]) ::
  {:ok, String.t()} | {:error, String.t()}

Destroys a specific version of secret at a specified path.

iex(2)> Ptolemy.Engines.KV.path_destroy(:production, "secret/destroy/ptolemy", [1,2])
{:ok, "KV secret destroyed"}
Link to this function

path_read(server_name, secret, silent \\ false, version \\ 0) View Source
path_read(atom(), String.t(), boolean(), integer()) ::
  {:ok, String.t()} | {:error, String.t()}

Fetches all of a given secret's key and values from a KV engine via the specified path.

This function returns the full reponse of the remote vault server, enabling the silent option will only return a map with the key and value of the secret. The version option will allow you to fetch specific version of the target secret.

Example

iex(2)> Ptolemy.Engines.KV.path_read(:production, "secret/data/ptolemy")
{:ok, %{
    "Foo" => test"
    ...
  }
}
Link to this function

path_update(server_name, secret, payload, cas \\ nil) View Source

Updates an already existing secret via the specified path.

Example

iex(2)> Ptolemy.Engines.KV.path_update(:production, "secret/data/ptolemy", %{test: "i am up-to-date from path"}, 1)
{:ok, "KV secret updated"}
Link to this function

read(server_name, engine_name, secret, silent \\ false, version \\ 0) View Source
read(atom(), atom(), atom(), boolean(), integer()) ::
  {:ok, String.t()} | {:error, String.t()}

Fetches all of a secret's keys and value via the :kv_engine configuration.

See fetch/2 for the description of the silent and version options.

Example

iex(2)> Ptolemy.Engines.KV.read(:production, :engine1, :ptolemy)
{:ok, %{
    "test" => i am some value"
    ...
  }
}
Link to this function

read!(server_name, engine_name, secret, silent \\ false, version \\ 0) View Source
read!(atom(), atom(), atom(), boolean(), integer()) :: any() | no_return()

Fetches all of a secret's keys and value via the :kv_engine configuration, errors out if an error occurs.

Link to this function

update(server_name, engine_name, secret, payload, cas \\ nil) View Source
update(atom(), atom(), atom(), map(), integer() | nil) ::
  {:ok, String.t()} | {:error, String.t()}

Updates an already existing secret via the :kv_engine configuration.

Example

iex(2)> Ptolemy.Engines.KV.update(:production, :engine1, :ptolemy, %{test: "i am  a new value from config"})
{:ok, "KV secret updated"}
Link to this function

update!(server_name, engine_name, secret, payload, cas \\ nil) View Source
update!(atom(), atom(), atom(), map(), integer() | nil) :: :ok | no_return()

Updates an already existing secret via the :kv_engine configuration, errors out if an error occurs.