TypeDB.GRPC.User (TypeDB.GRPC v0.1.0)

Copy Markdown View Source

Users, over the unary half of the protocol.

Mirrors TypeDB.User. list/2, get/3 and current/2 return names rather than richer records: the protocol's User message carries only a name and an optional password, and the password is never populated on the way out.

Summary

Functions

Creates a user, raising on failure.

The user this connection signed in as.

The user this connection signed in as, raising on failure.

Deletes a user, raising on failure.

Whether username exists.

A username, or an error when the user does not exist.

A username, raising when the user does not exist.

Every user on the server.

Every user on the server, raising on failure.

Sets a user's password, raising on failure.

Functions

create(conn, username, password, opts \\ [])

@spec create(TypeDB.GRPC.Connection.t(), String.t(), String.t(), keyword()) ::
  :ok | {:error, TypeDB.Error.t()}

Creates a user.

create!(conn, username, password, opts \\ [])

@spec create!(term(), term(), term(), term()) :: :ok

Creates a user, raising on failure.

current(conn, opts \\ [])

@spec current(
  TypeDB.GRPC.Connection.t(),
  keyword()
) :: {:ok, String.t()} | {:error, TypeDB.Error.t()}

The user this connection signed in as.

Rust's users().get_current(), and the same implementation: there is no RPC for it, so the name comes from the connection's own credentials and is then looked up — which means it also answers "does the account I am using still exist".

A connection configured with a pre-issued :token has no username to look up, and says so rather than guessing.

current!(conn, opts \\ [])

@spec current!(term(), term()) :: String.t()

The user this connection signed in as, raising on failure.

delete(conn, username, opts \\ [])

@spec delete(TypeDB.GRPC.Connection.t(), String.t(), keyword()) ::
  :ok | {:error, TypeDB.Error.t()}

Deletes a user.

delete!(conn, username, opts \\ [])

@spec delete!(term(), term(), term()) :: :ok

Deletes a user, raising on failure.

exists?(conn, username, opts \\ [])

@spec exists?(TypeDB.GRPC.Connection.t(), String.t(), keyword()) :: boolean()

Whether username exists.

Raises TypeDB.Error for anything but a clean answer — the same contract as TypeDB.User.exists?/3 and TypeDB.GRPC.Database.exists?/3. This used to return {:ok, boolean()}, which agreed with neither.

get(conn, username, opts \\ [])

@spec get(TypeDB.GRPC.Connection.t(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, TypeDB.Error.t()}

A username, or an error when the user does not exist.

The same contract as TypeDB.User.get/3: the answer to "is this user there" that can also say "I could not ask", which exists?/3 cannot.

get!(conn, username, opts \\ [])

@spec get!(term(), term(), term()) :: String.t()

A username, raising when the user does not exist.

list(conn, opts \\ [])

@spec list(
  TypeDB.GRPC.Connection.t(),
  keyword()
) :: {:ok, [String.t()]} | {:error, TypeDB.Error.t()}

Every user on the server.

list!(conn, opts \\ [])

@spec list!(term(), term()) :: [String.t()]

Every user on the server, raising on failure.

set_password(conn, username, password, opts \\ [])

@spec set_password(TypeDB.GRPC.Connection.t(), String.t(), String.t(), keyword()) ::
  :ok | {:error, TypeDB.Error.t()}

Sets a user's password.

set_password!(conn, username, password, opts \\ [])

@spec set_password!(term(), term(), term(), term()) :: :ok

Sets a user's password, raising on failure.