ExScim.Operations.Users (ex_scim v0.2.2)

Copy Markdown View Source

Orchestration layer for SCIM user operations.

Ties together schema validation, domain mapping, lifecycle hooks, and storage for each SCIM operation (GET, LIST, POST, PUT, PATCH, DELETE). This is the primary entry point used by controllers to execute user operations.

Summary

Functions

Creates a user from a SCIM JSON payload.

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

Retrieves a user by ID, applying lifecycle hooks and SCIM mapping. Returns {:ok, scim_user} or {:error, reason}.

Lists users as SCIM resources with filtering, sorting, and pagination.

Applies a SCIM PATCH operation to an existing user.

Fully replaces a user (PUT) from a SCIM JSON payload.

Functions

create_user_from_scim(scim_data, scope)

Creates a user from a SCIM JSON payload.

Validates the schema, maps to a domain struct, generates an ID if needed, runs lifecycle hooks, stores, and maps back to SCIM. Returns {:ok, scim_user} or {:error, reason}.

delete_user(user_id, scope)

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

get_user(id, scope)

Retrieves a user by ID, applying lifecycle hooks and SCIM mapping. Returns {:ok, scim_user} or {:error, reason}.

list_users_scim(scope, opts \\ %{})

Lists users as SCIM resources with filtering, sorting, and pagination.

opts may include :filter, :sort_by, :sort_order, :start_index, and :count. Returns {:ok, scim_users, total_count}.

patch_user_from_scim(user_id, scim_data, scope)

Applies a SCIM PATCH operation to an existing user.

Fetches the user, validates the patch payload, applies patch operations, runs lifecycle hooks, and stores. Returns {:ok, scim_user} or {:error, reason}.

replace_user_from_scim(user_id, scim_data, scope)

Fully replaces a user (PUT) from a SCIM JSON payload.

Verifies the user exists, validates, maps, runs lifecycle hooks, and stores. Returns {:ok, scim_user} or {:error, reason}.