ExScim.Operations.Groups (ex_scim v0.2.0)

Copy Markdown View Source

Orchestration layer for SCIM group 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 group operations.

Summary

Functions

Creates a group from a SCIM JSON payload.

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

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

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

Applies a SCIM PATCH operation to an existing group.

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

Functions

create_group_from_scim(scim_data, scope)

Creates a group 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_group} or {:error, reason}.

delete_group(group_id, scope)

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

get_group(id, scope)

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

list_groups_scim(scope, opts \\ %{})

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

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

patch_group_from_scim(group_id, scim_data, scope)

Applies a SCIM PATCH operation to an existing group.

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

replace_group_from_scim(group_id, scim_data, scope)

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

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