View Source Appwrite.Utils.Permission (appwrite v0.2.1)

Helpers for generating Appwrite permission strings.

Each function takes a role string (produced by Appwrite.Utils.Role) and wraps it in the appropriate permission verb expected by the Appwrite API.

Usage

alias Appwrite.Utils.Permission
alias Appwrite.Utils.Role

Permission.read(Role.any())           # => ~s|read("any")|
Permission.create(Role.users())       # => ~s|create("users")|
Permission.delete(Role.user("abc"))   # => ~s|delete("user:abc")|

Summary

Functions

Grants create access to role.

Grants delete access to role.

Grants read access to role.

Grants update access to role.

Grants write access to role.

Functions

create(role)

@spec create(String.t()) :: String.t()

Grants create access to role.

Examples

iex> Appwrite.Utils.Permission.create("users")
~s|create("users")|

delete(role)

@spec delete(String.t()) :: String.t()

Grants delete access to role.

Examples

iex> Appwrite.Utils.Permission.delete("user:123")
~s|delete("user:123")|

read(role)

@spec read(String.t()) :: String.t()

Grants read access to role.

Examples

iex> Appwrite.Utils.Permission.read("any")
~s|read("any")|

update(role)

@spec update(String.t()) :: String.t()

Grants update access to role.

Examples

iex> Appwrite.Utils.Permission.update("team:abc/admin")
~s|update("team:abc/admin")|

write(role)

@spec write(String.t()) :: String.t()

Grants write access to role.

This is a combined alias for create + update + delete. Avoid mixing write with the more granular verbs on the same resource.

Examples

iex> Appwrite.Utils.Permission.write("admin")
~s|write("admin")|