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
+14-11Lines changed: 14 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,26 +7,29 @@ Initialization
7
7
scim2-client depends on request engines such as `httpx <https://github.com/encode/httpx>`_ to perform network requests.
8
8
This tutorial demonstrate how to use scim2-client with httpx, and suppose you have installed the `httpx` extra for example with ``pip install scim2-models[httpx]``.
9
9
10
-
As a start you will need to instantiate a httpx :code:`Client` object that you can parameter as your will, and then pass it to a :class:`SCIM client <scim2_client.BaseSCIMClient>` object.
10
+
As a start you will need to instantiate a httpx :code:`Client` object that you can parameter as your will, and then pass it to a :class:`~scim2_client.SCIMClient` object.
11
11
In addition to your SCIM server root endpoint, you will probably want to provide some authorization headers through the httpx :code:`Client` :code:`headers` parameter:
12
12
13
13
.. code-block:: python
14
14
15
15
from httpx import Client
16
16
from scim2_client.engines.httpx import SyncSCIMClient
You need to give to indicate to :class:`~scim2_client.BaseSCIMClient` all the different :class:`~scim2_models.Resource` models that you will need to manipulate, and the matching :class:`~scim2_models.ResourceType` objects to let the client know where to look for resources on the server.
24
+
You need to give to indicate to :class:`~scim2_client.SCIMClient` all the different :class:`~scim2_models.Resource` models that you will need to manipulate, and the matching :class:`~scim2_models.ResourceType` objects to let the client know where to look for resources on the server.
22
25
23
26
You can either provision those objects manually or automatically.
24
27
25
28
Automatic provisioning
26
29
~~~~~~~~~~~~~~~~~~~~~~
27
30
28
31
The easiest way is to let the client discover what :class:`~scim2_models.Schema` and :class:`~scim2_models.ResourceType` are available on the server by calling :meth:`~scim2_client.BaseSyncSCIMClient.discover`.
29
-
It will dynamically generate models based on those schema, and make them available to use with :meth:`~scim2_client.BaseSCIMClient.get_resource_model`.
32
+
It will dynamically generate models based on those schema, and make them available to use with :meth:`~scim2_client.SCIMClient.get_resource_model`.
30
33
31
34
.. code-block:: python
32
35
:caption: Dynamically discover models from the server
@@ -36,7 +39,7 @@ It will dynamically generate models based on those schema, and make them availab
36
39
37
40
Manual provisioning
38
41
~~~~~~~~~~~~~~~~~~~
39
-
To manually register models and resource types, you can simply use the :paramref:`~scim2_client.BaseSCIMClient.resource_models` and :paramref:`~scim2_client.BaseSCIMClient.resource_types` arguments.
42
+
To manually register models and resource types, you can simply use the :paramref:`~scim2_client.SCIMClient.resource_models` and :paramref:`~scim2_client.SCIMClient.resource_types` arguments.
40
43
41
44
42
45
.. code-block:: python
@@ -54,7 +57,7 @@ To manually register models and resource types, you can simply use the :paramref
54
57
If you know that all the resources are hosted at regular server endpoints
55
58
(for instance `/Users` for :class:`~scim2_models.User` etc.),
56
59
you can skip passing the :class:`~scim2_models.ResourceType` objects by hand,
57
-
and simply call :meth:`~scim2_client.BaseSCIMClient.register_naive_resource_types`.
60
+
and simply call :meth:`~scim2_client.SCIMClient.register_naive_resource_types`.
58
61
59
62
.. code-block:: python
60
63
:caption: Manually registering models and resource types
@@ -99,20 +102,20 @@ Have a look at the :doc:`reference` to see usage examples and the exhaustive set
99
102
Request and response validation
100
103
===============================
101
104
102
-
By default, the data passed to the :class:`SCIM client <scim2_client.BaseSCIMClient>` as well as the server response will be validated against the SCIM specifications, and will raise an error if they don't respect them.
105
+
By default, the data passed to the :class:`SCIM client <scim2_client.SCIMClient>` as well as the server response will be validated against the SCIM specifications, and will raise an error if they don't respect them.
103
106
However sometimes you want to accept invalid inputs and outputs.
104
107
To achieve this, all the methods provide the following parameters, all are :data:`True` by default:
If :data:`True` (the default) a :class:`~pydantic.ValidationError` will be raised if the server response does not respect the SCIM standard.
111
114
If :data:`False` the server response is returned as-is.
112
115
- :code:`expected_status_codes`: The list of expected status codes in the response.
113
116
If :data:`None` any status code is accepted.
114
117
If an unexpected status code is returned, a :class:`~scim2_client.errors.UnexpectedStatusCode` exception is raised.
115
-
- :paramref:`~scim2_client.BaseSCIMClient.raise_scim_errors`: If :data:`True` (the default) and the server returned an :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject` exception will be raised.
118
+
- :paramref:`~scim2_client.SCIMClient.raise_scim_errors`: If :data:`True` (the default) and the server returned an :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject` exception will be raised.
116
119
If :data:`False` the error object is returned.
117
120
118
121
@@ -134,7 +137,7 @@ Currently those engines are shipped:
134
137
It takes a WSGI app and directly execute the server code instead of performing real HTTP requests.
135
138
This is faster in unit test suites, and helpful to catch the server exceptions.
136
139
137
-
You can easily implement your own engine by inheriting from :class:`~scim2_client.BaseSCIMClient`.
140
+
You can easily implement your own engine by inheriting from :class:`~scim2_client.SCIMClient`.
0 commit comments