WeaviateEx.RBAC.Actions (WeaviateEx v0.7.4)

View Source

Permission action types for Weaviate RBAC.

This module defines all supported actions for each permission type in Weaviate's RBAC system and provides conversion functions between Elixir atoms and API strings.

Permission Types and Actions

TypeActions
collectionscreate, read, update, delete, manage
datacreate, read, update, delete, manage
tenantscreate, read, update, delete
rolescreate, read, update, delete
userscreate, read, update, delete, assign_and_revoke
groupsread, assign_and_revoke
clusterread
nodesread
backupsmanage
replicatecreate, read, update, delete
aliascreate, read, update, delete

Examples

iex> Actions.to_api_string(:collections, :create)
"create_collections"

iex> Actions.from_api_string("read_data")
{:ok, {:data, :read}}

iex> Actions.valid_action?(:users, :assign_and_revoke)
true

Summary

Functions

Get all valid actions for a permission type.

Parse an API string to permission type and action tuple.

Get all permission types.

Convert a permission type and action to the API string format.

Check if an action is valid for the given permission type.

Types

action()

alias_action()

@type alias_action() :: :create | :read | :update | :delete

backups_action()

@type backups_action() :: :manage

cluster_action()

@type cluster_action() :: :read

collections_action()

@type collections_action() :: :create | :read | :update | :delete | :manage

data_action()

@type data_action() :: :create | :read | :update | :delete | :manage

groups_action()

@type groups_action() :: :read | :assign_and_revoke

nodes_action()

@type nodes_action() :: :read

permission_type()

@type permission_type() ::
  :collections
  | :data
  | :tenants
  | :roles
  | :users
  | :groups
  | :cluster
  | :nodes
  | :backups
  | :replicate
  | :alias

replicate_action()

@type replicate_action() :: :create | :read | :update | :delete

roles_action()

@type roles_action() :: :create | :read | :update | :delete

tenants_action()

@type tenants_action() :: :create | :read | :update | :delete

users_action()

@type users_action() :: :create | :read | :update | :delete | :assign_and_revoke

Functions

actions_for_type(type)

@spec actions_for_type(permission_type()) :: [action()]

Get all valid actions for a permission type.

Examples

iex> Actions.actions_for_type(:collections)
[:create, :read, :update, :delete, :manage]

iex> Actions.actions_for_type(:cluster)
[:read]

from_api_string(api_string)

@spec from_api_string(String.t()) ::
  {:ok, {permission_type(), action()}} | {:error, String.t()}

Parse an API string to permission type and action tuple.

Examples

iex> Actions.from_api_string("create_collections")
{:ok, {:collections, :create}}

iex> Actions.from_api_string("unknown_action")
{:error, "Unknown action: unknown_action"}

permission_types()

@spec permission_types() :: [permission_type()]

Get all permission types.

Examples

iex> Actions.permission_types()
[:collections, :data, :tenants, :roles, :users, :groups, :cluster, :nodes, :backups, :replicate, :alias]

to_api_string(type, action)

@spec to_api_string(permission_type(), action()) :: String.t()

Convert a permission type and action to the API string format.

Examples

iex> Actions.to_api_string(:collections, :create)
"create_collections"

iex> Actions.to_api_string(:users, :assign_and_revoke)
"assign_and_revoke_users"

valid_action?(type, action)

@spec valid_action?(permission_type(), action()) :: boolean()

Check if an action is valid for the given permission type.

Examples

iex> Actions.valid_action?(:collections, :create)
true

iex> Actions.valid_action?(:nodes, :delete)
false