You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/tutorial.rst
+17-16Lines changed: 17 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ Use Pydantic's :func:`~scim2_models.BaseModel.model_validate` method to parse an
59
59
Model serialization
60
60
===================
61
61
62
-
Pydantic :func:`~scim2_models.BaseModel.model_dump` method have been tuned to produce valid SCIM2 payloads.
62
+
Pydantic :func:`~scim2_models.BaseModel.model_dump` method has been tuned to produce valid SCIM2 payloads.
63
63
64
64
.. code-block:: python
65
65
:emphasize-lines: 16
@@ -99,7 +99,7 @@ Contexts
99
99
========
100
100
101
101
The SCIM specifications detail some :class:`~scim2_models.Mutability` and :class:`~scim2_models.Returned` parameters for model attributes.
102
-
Depending on the context, they will indicate that attributes should be present, absent, be ignored.
102
+
Depending on the context, they will indicate that attributes should be present, absent, or ignored.
103
103
104
104
For instance, attributes marked as :attr:`~scim2_models.Mutability.read_only` should not be sent by SCIM clients on resource creation requests.
105
105
By passing the right :class:`~scim2_models.Context` to the :meth:`~scim2_models.BaseModel.model_dump` method, only the expected fields will be dumped for this context:
@@ -117,11 +117,11 @@ fields with unexpected values will raise :class:`~pydantic.ValidationError`:
117
117
.. code-block:: python
118
118
:caption: Server validating a resource creation request payload
Values read from :attr:`~scim2_models.SearchRequest.attributes` and :attr:`~scim2_models.SearchRequest.excluded_attributes` in :class:`~scim2_models.SearchRequest` objects can directly be used in :meth:`~scim2_models.BaseModel.model_dump`.
235
234
236
-
Attribute inclusions and exclusions interact with attributes :class:`~scim2_models.Returned`, in the server response :class:`Contexts <scim2_models.Context>`:
235
+
Attributes inclusions and exclusions interact with attributes :class:`~scim2_models.Returned`, in the server response :class:`Contexts <scim2_models.Context>`:
237
236
238
237
- attributes annotated with :attr:`~scim2_models.Returned.always` will always be dumped;
239
238
- attributes annotated with :attr:`~scim2_models.Returned.never` will never be dumped;
240
239
- attributes annotated with :attr:`~scim2_models.Returned.default` will be dumped unless being explicitly excluded;
241
-
- attributes annotated with :attr:`~scim2_models.Returned.request` will be not dumped unless being explicitly included.
240
+
- attributes annotated with :attr:`~scim2_models.Returned.request` will not be dumped unless being explicitly included.
242
241
243
242
Typed ListResponse
244
243
==================
@@ -403,7 +402,7 @@ Use :meth:`Error.from_validation_error <scim2_models.Error.from_validation_error
@@ -427,7 +426,7 @@ The exhaustive list of exceptions is available in the :class:`reference <scim2_m
427
426
Custom models
428
427
=============
429
428
430
-
You can write your own model and use it the same way than the other scim2-models models.
429
+
You can write your own model and use it the same way as the other scim2-models models.
431
430
Just inherit from :class:`~scim2_models.Resource` for your main resource, or :class:`~scim2_models.Extension` for extensions.
432
431
Use :class:`~scim2_models.ComplexAttribute` as base class for complex attributes:
433
432
@@ -464,8 +463,11 @@ If unset the default values will be :attr:`~scim2_models.Mutability.read_write`
464
463
There is a dedicated type for :rfc:`RFC7643 §2.3.7 <7643#section-2.3.7>` :class:`~scim2_models.Reference`
465
464
that can take type parameters to represent :rfc:`RFC7643 §7 'referenceTypes'<7643#section-7>`:
466
465
466
+
.. code-block:: python
467
+
468
+
>>>from scim2_models import Reference
467
469
>>>classPetOwner(Resource):
468
-
... pet: Reference["Pet"]
470
+
... pet: Optional[Reference["Pet"]]
469
471
470
472
:class:`~scim2_models.Reference` has two special type parameters :class:`~scim2_models.External` and :class:`~scim2_models.URI` that matches :rfc:`RFC7643 §7 <7643#section-7>` external and URI reference types.
471
473
@@ -541,7 +543,7 @@ with the :meth:`Resource.from_schema <scim2_models.Resource.from_schema>` and :m
541
543
Group = Resource.from_schema(schema)
542
544
my_group = Group(display_name="This is my group")
543
545
544
-
Client applications can use this to dynamically discover server resources by browsing the `/Schemas` endpoint.
546
+
Client applications can use this to dynamically discover server resources by browsing the ``/Schemas`` endpoint.
545
547
546
548
.. tip::
547
549
@@ -550,7 +552,7 @@ Client applications can use this to dynamically discover server resources by bro
>>> from scim2_models.exceptions import MutabilityException
570
571
>>> existing = User(user_name="bjensen")
571
572
>>> replacement = User.model_validate(
572
573
... {"userName": "bjensen"},
@@ -581,7 +582,7 @@ Patch operations
581
582
================
582
583
583
584
:class:`~scim2_models.PatchOp` allows you to apply patch operations to modify SCIM resources.
584
-
The :meth:`~scim2_models.PatchOp.patch` method applies operations in sequence and returns whether the resource was modified. The return code is a boolean indicating whether the object have been modified by the operations.
585
+
The :meth:`~scim2_models.PatchOp.patch` method applies operations in sequence and returns whether the resource was modified. The return code is a boolean indicating whether the object has been modified by the operations.
585
586
586
587
.. note::
587
588
:class:`~scim2_models.PatchOp` takes a type parameter that should be the class of the resource
0 commit comments