User administration.
Most of these endpoints require administrator rights; a non-admin user can generally read and update only its own record.
{:ok, usernames} = TypeDB.User.list(conn)
:ok = TypeDB.User.create(conn, "alice", "s3cret")
:ok = TypeDB.User.set_password(conn, "alice", "even-more-s3cret")
:ok = TypeDB.User.delete(conn, "alice")
Summary
Functions
Creates a user with the given password.
Creates a user, raising on failure.
Deletes a user.
Deletes a user, raising on failure.
Returns whether a user exists.
Returns a username, or an error when the user does not exist.
Returns a username, raising when the user does not exist.
Lists all usernames.
Lists all usernames, raising on failure.
Replaces a user's password.
Replaces a user's password, raising on failure.
Functions
@spec create(TypeDB.Connection.t(), String.t(), String.t()) :: :ok | {:error, TypeDB.Error.t()}
Creates a user with the given password.
@spec create!(TypeDB.Connection.t(), String.t(), String.t()) :: :ok
Creates a user, raising on failure.
@spec delete(TypeDB.Connection.t(), String.t()) :: :ok | {:error, TypeDB.Error.t()}
Deletes a user.
@spec delete!(TypeDB.Connection.t(), String.t()) :: :ok
Deletes a user, raising on failure.
@spec exists?(TypeDB.Connection.t(), String.t()) :: boolean()
Returns whether a user exists.
Raises TypeDB.Error for anything other than a clean "not found" — an
unreachable server, a rejected token, a 500. A boolean cannot express "I could
not ask", and answering false to that question is the answer that makes a
caller do the wrong thing: unless exists?(conn, x), do: create(conn, x) would
try to create while the server is down. Use get/2 if you would rather branch
on the error yourself.
@spec get(TypeDB.Connection.t(), String.t()) :: {:ok, String.t()} | {:error, TypeDB.Error.t()}
Returns a username, or an error when the user does not exist.
@spec get!(TypeDB.Connection.t(), String.t()) :: String.t()
Returns a username, raising when the user does not exist.
@spec list(TypeDB.Connection.t()) :: {:ok, [String.t()]} | {:error, TypeDB.Error.t()}
Lists all usernames.
@spec list!(TypeDB.Connection.t()) :: [String.t()]
Lists all usernames, raising on failure.
@spec set_password(TypeDB.Connection.t(), String.t(), String.t()) :: :ok | {:error, TypeDB.Error.t()}
Replaces a user's password.
Existing tokens issued to that user are not revoked by this call; they expire on their own schedule.
@spec set_password!(TypeDB.Connection.t(), String.t(), String.t()) :: :ok
Replaces a user's password, raising on failure.