Mapping#
The classes describing how SCIM resources are stored in SQLAlchemy models.
- class scim2_sqlalchemy.ResourceMapping(model, record, attributes, *, version)[source]#
How the resources of a SCIM model are stored in the records of a SQLAlchemy model.
The paths are checked against the SCIM model when the mapping is created, so a mistake raises at import time rather than at the first request.
- Parameters:
model (type[Resource]) – The SCIM model of the resources, such as
User[EnterpriseUser].attributes (Mapping[str, Any]) – The attributes, by SCIM path. A value is a column, a
hybrid_property, anAttribute, aManyor aLink.id,meta.createdandmeta.lastModifiedare required.version (Any) – The
version_id_colof the mapper ofrecord, which givesmeta.version(Configuring a Version Counter).
- Raises:
ValueError – When a path is not valid for the model, or when a value does not fit the attribute of its path.
- schemas()[source]#
Return the schemas of the resources, restricted to what the mapping stores.
They hold the mapped attributes only, and an attribute the mapping reads but never writes is
readOnly. Publish them, rather than the schemas ofmodel, so that clients know what the server stores: build the provider of the server withScimProvider.from_discovery, and pass it to the storage.
- class scim2_sqlalchemy.Attribute(expression, *, readable=True, writable=True)[source]#
A column holding a SCIM attribute that the storage only reads, or only writes.
To store a value in another form, map the attribute to a
hybrid_propertythat converts it, in Python and in SQL.- Parameters:
expression (Any) – The column, or the
hybrid_property, holding the value.readable (bool) – Whether the storage reads the attribute. When
False, the attribute is write-only, such as a password: the storage never returns it, nor filters or sorts on it.writable (bool) – Whether the storage writes the attribute. When
False, the attribute is read-only.
- class scim2_sqlalchemy.Many(relationship, attributes)[source]#
The entries of a multi-valued complex attribute, stored in a child table.
The entries belong to the resource: writing the resource replaces them. The relationship needs
cascade="all, delete-orphan"(delete-orphan). Itsorder_bygives the order of the entries. A sort uses theprimaryentry, or else the first one.- Parameters:
relationship (Any) – The
relationship()from the resource record to the entry records.attributes (Mapping[str, Any]) – The columns of the entry records, by sub-attribute name, such as
"value"or"type".
- class scim2_sqlalchemy.Link(relationship, resource_type)[source]#
A complex attribute linking to other resources.
A multi-valued attribute, such as the
membersof a group, maps to a relationship holding several records. A single-valued one, such as themanagerof an enterprise user, maps to a relationship holding one record.valueis theidof the linked resource. Its display name, thedisplayordisplayNamesub-attribute, is thedisplayNameof the linked resource when its mapping has one, or else itsuserName. Writing the resource changes the links, and never creates nor deletes the linked resources.- Parameters:
relationship (Any) – The
relationship()from the resource record to the records of the linked resources.resource_type (str) – The name of the resource type of the linked resources, as the storage knows it.