View Source Glific.AccessControl.TriggerRole (Glific v5.1.6)

A pipe for managing the role triggers

Link to this section Summary

Functions

Standard changeset pattern we use for all data types

Filtering entity object based on user role

Creates a access control.

Update trigger roles based on add_role_ids and delete_role_ids and return number_deleted as integer and roles added as access_controls

Link to this section Types

@type t() :: %Glific.AccessControl.TriggerRole{
  __meta__: Ecto.Schema.Metadata.t(),
  id: non_neg_integer() | nil,
  organization:
    Glific.Partners.Organization.t() | Ecto.Association.NotLoaded.t() | nil,
  organization_id: non_neg_integer() | nil,
  role: Glific.AccessControl.Role.t() | Ecto.Association.NotLoaded.t() | nil,
  role_id: term(),
  trigger: Glific.Triggers.Trigger.t() | Ecto.Association.NotLoaded.t() | nil,
  trigger_id: term()
}

Link to this section Functions

Link to this function

changeset(role_trigger, attrs)

View Source
@spec changeset(t(), map()) :: Ecto.Changeset.t()

Standard changeset pattern we use for all data types

Link to this function

check_access(entity_list, user)

View Source
@spec check_access(Ecto.Query.t(), Glific.Users.User.t()) :: Ecto.Query.t()

Filtering entity object based on user role

Link to this function

create_trigger_role(attrs \\ %{})

View Source
@spec create_trigger_role(map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Creates a access control.

examples

Examples

iex> create_trigger_role(%{field: value})
{:ok, %TriggerRole{}}
iex> create_trigger_role(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

delete_trigger_roles_by_role_ids(trigger_id, role_ids)

View Source
@spec delete_trigger_roles_by_role_ids(integer(), list()) ::
  {integer(), nil | [term()]}

Delete trigger roles

Link to this function

update_trigger_roles(attrs)

View Source
@spec update_trigger_roles(map()) :: map()

Update trigger roles based on add_role_ids and delete_role_ids and return number_deleted as integer and roles added as access_controls