Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

[Unreleased]
------------

Added
^^^^^
- :mod:`scim2_server.mapping` is the base of the storages that map SCIM resources to the records
of an ORM: the declaration of a mapping, its checks, the translation of the filters and of the
sorts into the conditions of the ORM, the reading of the records, and the checks of the writes.
scim2-django and scim2-sqlalchemy build on it. Its API may change in any minor version.

[0.8.9] - 2026-11-26
--------------------

Expand Down
2 changes: 2 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
nitpick_ignore_regex = [
("py:class", r"collections\.abc\.Callable\[\[\]"),
("py:class", r"dict\[str"),
("py:class", r"dict\[str \| None"),
("py:class", r"collections\.abc\.Mapping\[str"),
]

Expand All @@ -98,6 +99,7 @@
("py:class", "scim2_server.service.ModelT"),
("py:class", "scim2_server.service.DiscoveryResourceT"),
("py:class", "scim2_server.testing.T"),
("py:class", "scim2_server.mapping.filters.C"),
("py:class", "ModelT"),
("py:class", "DiscoveryResourceT"),
("py:class", "T"),
Expand Down
1 change: 1 addition & 0 deletions doc/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Storage
:maxdepth: 1

storages
mapping
testing

Test server
Expand Down
62 changes: 62 additions & 0 deletions doc/reference/mapping.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Mapping core
============

The base of the storages that map SCIM resources to the records of an ORM. It holds the SCIM
rules, and a backend gives the primitives of its ORM. scim2-django and scim2-sqlalchemy build on
it.

.. warning::

This API follows the needs of these backends, and may change in any minor version.

.. automodule:: scim2_server.mapping

Backend hooks
-------------

A backend subclasses :class:`~scim2_server.mapping.ResourceMapping` and overrides these methods:

- ``_is_target(value)`` tells whether a value is a target of the ORM, such as a field;
- ``_check_declared(path, binding, value, holder)`` refuses a value the backend cannot map, by
raising :class:`ValueError`;
- ``_build_column(path, binding, value, owner)`` and ``_build_collection(path, binding,
declaration)`` build the descriptors, and yield a :class:`~scim2_server.mapping.MappingProblem`
for a target that does not fit;
- ``_check_record()`` and ``_fields_needing_value()`` give the problems and the fields of the
record;
- ``_links_to(collection, target)`` tells whether a Link holds the records of a target mapping;
- ``_read(column, record)``, ``_related(collection, record)``, ``_counter(record)`` and
``_holds_id(record, value)`` read the records.

The backend calls ``_resolve()`` once its models are ready, and gets the problems of the mapping.
A storage then calls ``_targets(mappings)`` on every mapping, then ``_bind(targets)``, so that a
refused mapping binds nothing.

Declaration
-----------

.. automodule:: scim2_server.mapping.declaration
:members: Attribute, Many, Entry, Link

Resolution
----------

.. autoclass:: scim2_server.mapping.ResourceMapping
:members: schemas

.. autoclass:: scim2_server.mapping.MappingProblem

.. automodule:: scim2_server.mapping.descriptors
:members: Storage, Column, Collection, EntryColumns

Filters and sorts
-----------------

.. automodule:: scim2_server.mapping.filters
:members: Predicates, where, compare, present, entry_present, sort_target, holds

Reading and writing
-------------------

.. automodule:: scim2_server.mapping.conversion
:members: to_scim, version_hash, check_storable, write_plan, keeps, dates, entries, link_entries, assign_links, same_type, comparable
38 changes: 38 additions & 0 deletions scim2_server/mapping/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""The base of the storages that map SCIM resources to the records of an ORM.

A backend declares how each attribute is stored, and gives the primitives of
its ORM. The core holds the SCIM rules: the checks of the mappings, the
translation of the filters and of the sorts, the reading of the records and
the checks of the writes. scim2-django and scim2-sqlalchemy build on it.

.. warning::

This API follows the needs of these backends, and may change in any minor
version.
"""

from .declaration import Attribute
from .declaration import Entry
from .declaration import Link
from .declaration import Many
from .descriptors import Collection
from .descriptors import Column
from .descriptors import EntryColumns
from .descriptors import Storage
from .filters import Predicates
from .mapping import MappingProblem
from .mapping import ResourceMapping

__all__ = [
"Attribute",
"Collection",
"Column",
"Entry",
"EntryColumns",
"Link",
"Many",
"MappingProblem",
"Predicates",
"ResourceMapping",
"Storage",
]
Loading
Loading