ExScim.Storage (ex_scim v0.2.2)

Copy Markdown View Source

Storage interface for SCIM resources using configurable adapters.

This module provides a unified interface for storing and retrieving Users and Groups. The actual storage implementation is configurable via the :storage_strategy config.

Configuration

config :ex_scim, storage_strategy: MyApp.CustomStorage

Examples

iex> ExScim.Storage.adapter()
ExScim.Storage.EtsStorage

Summary

Functions

Returns the configured storage adapter module.

Creates a new group. Returns {:ok, group} or {:error, reason}.

Creates a new user with the provided data.

Deletes a group by ID. Returns :ok or {:error, reason}.

Deletes a user by ID. Returns :ok or {:error, reason}.

Retrieves a group by ID. Returns {:ok, group} or {:error, :not_found}.

Retrieves a user by ID.

Returns true if a group with the given ID exists.

Lists groups matching the given filter, sort, and pagination options.

Lists users matching the given filter, sort, and pagination options.

Fully replaces an existing group. Returns {:ok, group} or {:error, reason}.

Fully replaces an existing user. Returns {:ok, user} or {:error, reason}.

Partially updates an existing group. Returns {:ok, group} or {:error, reason}.

Partially updates an existing user. Returns {:ok, user} or {:error, reason}.

Returns true if a user with the given ID exists.

Functions

adapter()

Returns the configured storage adapter module.

Examples

iex> ExScim.Storage.adapter()
ExScim.Storage.EtsStorage

create_group(group_data, scope \\ nil)

Creates a new group. Returns {:ok, group} or {:error, reason}.

create_user(user_data, scope \\ nil)

Creates a new user with the provided data.

delete_group(group_id, scope \\ nil)

Deletes a group by ID. Returns :ok or {:error, reason}.

delete_user(user_id, scope \\ nil)

Deletes a user by ID. Returns :ok or {:error, reason}.

get_group(group_id, scope \\ nil)

Retrieves a group by ID. Returns {:ok, group} or {:error, :not_found}.

get_user(user_id, scope \\ nil)

Retrieves a user by ID.

Examples

iex> ExScim.Storage.get_user("123")
{:ok, %{"id" => "123", "userName" => "john"}}

iex> ExScim.Storage.get_user("nonexistent")
{:error, :not_found}

group_exists?(group_id, scope \\ nil)

Returns true if a group with the given ID exists.

list_groups(filter_ast, sort_opts, pagination_opts, scope \\ nil)

Lists groups matching the given filter, sort, and pagination options.

Returns {:ok, groups, total_count}.

list_users(filter_ast, sort_opts, pagination_opts, scope \\ nil)

Lists users matching the given filter, sort, and pagination options.

Returns {:ok, users, total_count} where total_count is the total number of matching users before pagination.

replace_group(group_id, group_data, scope \\ nil)

Fully replaces an existing group. Returns {:ok, group} or {:error, reason}.

replace_user(user_id, user_data, scope \\ nil)

Fully replaces an existing user. Returns {:ok, user} or {:error, reason}.

update_group(group_id, group_data, scope \\ nil)

Partially updates an existing group. Returns {:ok, group} or {:error, reason}.

update_user(user_id, user_data, scope \\ nil)

Partially updates an existing user. Returns {:ok, user} or {:error, reason}.

user_exists?(user_id, scope \\ nil)

Returns true if a user with the given ID exists.