Arangox.API.Users (Arangox v0.8.0)

Copy Markdown View Source

ArangoDB's Users operations.

Every function takes the pool as its first argument and returns the decoded response body. See Arangox.API.Client for the options they all accept and for what a 404 returns.

Summary

Functions

List available users

List available users. Raises on error.

List a user’s accessible databases

List a user’s accessible databases. Raises on error.

Get a user’s collection access level

Get a user’s collection access level. Raises on error.

Create a user. Raises on error.

Get a user’s database access level

Get a user’s database access level. Raises on error.

Remove a user. Raises on error.

Clear a user’s collection access level. Raises on error.

Clear a user’s database access level

Clear a user’s database access level. Raises on error.

Get a user. Raises on error.

Replace a user. Raises on error.

Set a user’s collection access level. Raises on error.

Set a user’s database access level

Set a user’s database access level. Raises on error.

Update a user. Raises on error.

Functions

all(conn, opts \\ [])

@spec all(
  Arangox.conn(),
  keyword()
) :: {:ok, term()} | {:error, Exception.t()}

List available users

Fetches data about all users. You need the Administrate server access level in order to execute this REST call. Otherwise, you will only get information about yourself.

The call will return a JSON object with at least the following attributes on success:

  • user: The name of the user as a string.
  • active: Whether the user account is able to log in to the database system.
  • extra: A JSON object with extra user information. It is used by the web interface to store graph viewer settings and saved queries.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "result" => [%{
    "active" => boolean,
    "extra" => %{},
    "user" => string
  }]
}

all!(conn, opts \\ [])

@spec all!(
  Arangox.conn(),
  keyword()
) :: term()

List available users. Raises on error.

See all/1.

all_databases(conn, user, opts \\ [])

@spec all_databases(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

List a user’s accessible databases

Fetch the list of databases available to the specified user.

You need Administrate permissions for the server access level in order to execute this REST call.

The call will return a JSON object with the per-database access privileges for the specified user. The result object will contain the databases names as object keys, and the associated privileges for the database as values.

In case you specified full, the result will contain the permissions for the databases as well as the permissions for the collections.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "result" => %{}
}

all_databases!(conn, user, opts \\ [])

@spec all_databases!(Arangox.conn(), binary(), keyword()) :: term()

List a user’s accessible databases. Raises on error.

See all_databases/2.

collection_permissions(conn, user, dbname, collection, opts \\ [])

@spec collection_permissions(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Get a user’s collection access level

Returns the collection access level for a specific collection

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "result" => string
}

collection_permissions!(conn, user, dbname, collection, opts \\ [])

@spec collection_permissions!(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  term()

Get a user’s collection access level. Raises on error.

See collection_permissions/4.

create(conn, body, opts \\ [])

@spec create(Arangox.conn(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Create a user

Create a new user. You need server access level Administrate in order to execute this REST call.

create!(conn, body, opts \\ [])

@spec create!(Arangox.conn(), term(), keyword()) :: term()

Create a user. Raises on error.

See create/2.

database_permissions(conn, user, dbname, opts \\ [])

@spec database_permissions(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Get a user’s database access level

Fetch the database access level for a specific database

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "result" => string
}

database_permissions!(conn, user, dbname, opts \\ [])

@spec database_permissions!(Arangox.conn(), binary(), binary(), keyword()) :: term()

Get a user’s database access level. Raises on error.

See database_permissions/3.

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

@spec delete(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Remove a user

Removes an existing user, identified by user.

You need Administrate permissions for the server access level in order to execute this REST call.

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

@spec delete!(Arangox.conn(), binary(), keyword()) :: term()

Remove a user. Raises on error.

See delete/2.

delete_collection_permissions(conn, user, dbname, collection, opts \\ [])

@spec delete_collection_permissions(
  Arangox.conn(),
  binary(),
  binary(),
  binary(),
  keyword()
) ::
  {:ok, term()} | {:error, Exception.t()}

Clear a user’s collection access level

Clears the collection access level for the collection collection in the database dbname of user user. As consequence, the default collection access level is used. If there is no defined default collection access level, it defaults to No access.

You need write permissions (Administrate access level) for the _system database in order to execute this REST call.

delete_collection_permissions!(conn, user, dbname, collection, opts \\ [])

@spec delete_collection_permissions!(
  Arangox.conn(),
  binary(),
  binary(),
  binary(),
  keyword()
) :: term()

Clear a user’s collection access level. Raises on error.

See delete_collection_permissions/4.

delete_database_permissions(conn, user, dbname, opts \\ [])

@spec delete_database_permissions(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Clear a user’s database access level

Clears the database access level for the database dbname of user user. As consequence, the default database access level is used. If there is no defined default database access level, it defaults to No access.

You need write permissions (Administrate access level) for the _system database in order to execute this REST call.

delete_database_permissions!(conn, user, dbname, opts \\ [])

@spec delete_database_permissions!(Arangox.conn(), binary(), binary(), keyword()) ::
  term()

Clear a user’s database access level. Raises on error.

See delete_database_permissions/3.

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

@spec get(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Get a user

Fetches data about the specified user. You can fetch information about yourself or you need the Administrate server access level in order to execute this REST call.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "active" => boolean,
  "code" => integer,
  "error" => boolean,
  "extra" => %{},
  "user" => string
}

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

@spec get!(Arangox.conn(), binary(), keyword()) :: term()

Get a user. Raises on error.

See get/2.

replace(conn, user, body, opts \\ [])

@spec replace(Arangox.conn(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Replace a user

Replaces the data of an existing user. This resets the user's access levels for databases and collections. You need server access level Administrate in order to execute this REST call. Additionally, users can change their own data.

replace!(conn, user, body, opts \\ [])

@spec replace!(Arangox.conn(), binary(), term(), keyword()) :: term()

Replace a user. Raises on error.

See replace/3.

set_collection_permissions(conn, user, dbname, collection, body, opts \\ [])

@spec set_collection_permissions(
  Arangox.conn(),
  binary(),
  binary(),
  binary(),
  term(),
  keyword()
) ::
  {:ok, term()} | {:error, Exception.t()}

Set a user’s collection access level

Sets the collection access level for the collection in the database dbname for user user. You need the Administrate server access level in order to execute this REST call.

set_collection_permissions!(conn, user, dbname, collection, body, opts \\ [])

@spec set_collection_permissions!(
  Arangox.conn(),
  binary(),
  binary(),
  binary(),
  term(),
  keyword()
) ::
  term()

Set a user’s collection access level. Raises on error.

See set_collection_permissions/5.

set_database_permissions(conn, user, dbname, body, opts \\ [])

@spec set_database_permissions(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Set a user’s database access level

Sets the database access levels for the database dbname of user user. You need the Administrate server access level in order to execute this REST call.

set_database_permissions!(conn, user, dbname, body, opts \\ [])

@spec set_database_permissions!(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  term()

Set a user’s database access level. Raises on error.

See set_database_permissions/4.

update(conn, user, body, opts \\ [])

@spec update(Arangox.conn(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Update a user

Partially modifies the data of an existing user. You need server access level Administrate in order to execute this REST call. Additionally, users can change their own data.

update!(conn, user, body, opts \\ [])

@spec update!(Arangox.conn(), binary(), term(), keyword()) :: term()

Update a user. Raises on error.

See update/3.