scim2-client 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
scim2_client/client.py CHANGED
@@ -1,11 +1,7 @@
1
1
  import json
2
2
  import json.decoder
3
3
  import sys
4
- from typing import Dict
5
- from typing import List
6
4
  from typing import Optional
7
- from typing import Tuple
8
- from typing import Type
9
5
  from typing import Union
10
6
 
11
7
  from httpx import Client
@@ -52,7 +48,7 @@ class SCIMClient:
52
48
  :class:`~scim2_models.ResourceType`, :class:`~scim2_models.Schema` and :class:`scim2_models.ServiceProviderConfig` are pre-loaded by default.
53
49
  """
54
50
 
55
- CREATION_RESPONSE_STATUS_CODES: List[int] = [
51
+ CREATION_RESPONSE_STATUS_CODES: list[int] = [
56
52
  201,
57
53
  409,
58
54
  307,
@@ -69,14 +65,14 @@ class SCIMClient:
69
65
  :rfc:`RFC7644 §3.12 <7644#section-3.12>`.
70
66
  """
71
67
 
72
- QUERY_RESPONSE_STATUS_CODES: List[int] = [200, 400, 307, 308, 401, 403, 404, 500]
68
+ QUERY_RESPONSE_STATUS_CODES: list[int] = [200, 400, 307, 308, 401, 403, 404, 500]
73
69
  """Resource querying HTTP codes.
74
70
 
75
71
  As defined at :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2>` and
76
72
  :rfc:`RFC7644 §3.12 <7644#section-3.12>`.
77
73
  """
78
74
 
79
- SEARCH_RESPONSE_STATUS_CODES: List[int] = [
75
+ SEARCH_RESPONSE_STATUS_CODES: list[int] = [
80
76
  200,
81
77
  307,
82
78
  308,
@@ -95,7 +91,7 @@ class SCIMClient:
95
91
  :rfc:`RFC7644 §3.12 <7644#section-3.12>`.
96
92
  """
97
93
 
98
- DELETION_RESPONSE_STATUS_CODES: List[int] = [
94
+ DELETION_RESPONSE_STATUS_CODES: list[int] = [
99
95
  204,
100
96
  307,
101
97
  308,
@@ -113,7 +109,7 @@ class SCIMClient:
113
109
  :rfc:`RFC7644 §3.12 <7644#section-3.12>`.
114
110
  """
115
111
 
116
- REPLACEMENT_RESPONSE_STATUS_CODES: List[int] = [
112
+ REPLACEMENT_RESPONSE_STATUS_CODES: list[int] = [
117
113
  200,
118
114
  307,
119
115
  308,
@@ -132,7 +128,7 @@ class SCIMClient:
132
128
  :rfc:`RFC7644 §3.12 <7644#section-3.12>`.
133
129
  """
134
130
 
135
- def __init__(self, client: Client, resource_types: Optional[Tuple[Type]] = None):
131
+ def __init__(self, client: Client, resource_types: Optional[tuple[type]] = None):
136
132
  self.client = client
137
133
  self.resource_types = tuple(
138
134
  set(resource_types or []) | {ResourceType, Schema, ServiceProviderConfig}
@@ -142,7 +138,7 @@ class SCIMClient:
142
138
  if resource_type not in self.resource_types:
143
139
  raise SCIMRequestError(f"Unknown resource type: '{resource_type}'")
144
140
 
145
- def resource_endpoint(self, resource_type: Type):
141
+ def resource_endpoint(self, resource_type: type):
146
142
  if resource_type is None:
147
143
  return "/"
148
144
 
@@ -160,8 +156,8 @@ class SCIMClient:
160
156
  def check_response(
161
157
  self,
162
158
  response: Response,
163
- expected_status_codes: List[int],
164
- expected_types: Optional[Type] = None,
159
+ expected_status_codes: list[int],
160
+ expected_types: Optional[type] = None,
165
161
  check_response_payload: bool = True,
166
162
  raise_scim_errors: bool = True,
167
163
  scim_ctx: Optional[Context] = None,
@@ -175,11 +171,9 @@ class SCIMClient:
175
171
  # SCIM are known to informally use "application/json".
176
172
  # https://datatracker.ietf.org/doc/html/rfc7644.html#section-8.1
177
173
 
174
+ actual_content_type = response.headers.get("content-type", "").split(";").pop(0)
178
175
  expected_response_content_types = ("application/scim+json", "application/json")
179
- if (
180
- response.headers.get("content-type").split(";").pop(0)
181
- not in expected_response_content_types
182
- ):
176
+ if actual_content_type not in expected_response_content_types:
183
177
  raise UnexpectedContentType(source=response)
184
178
 
185
179
  # In addition to returning an HTTP response code, implementers MUST return
@@ -219,7 +213,7 @@ class SCIMClient:
219
213
  expected = ", ".join([type.__name__ for type in expected_types])
220
214
  try:
221
215
  schema = ", ".join(response_payload["schemas"])
222
- message = f"Expected type {expected} but got unknow resource with schemas: {schema}"
216
+ message = f"Expected type {expected} but got unknown resource with schemas: {schema}"
223
217
  except KeyError:
224
218
  message = (
225
219
  f"Expected type {expected} but got undefined object with no schema"
@@ -237,15 +231,14 @@ class SCIMClient:
237
231
 
238
232
  def create(
239
233
  self,
240
- resource: Union[AnyResource, Dict],
234
+ resource: Union[AnyResource, dict],
241
235
  check_request_payload: bool = True,
242
236
  check_response_payload: bool = True,
243
- expected_status_codes: Optional[List[int]] = CREATION_RESPONSE_STATUS_CODES,
237
+ expected_status_codes: Optional[list[int]] = CREATION_RESPONSE_STATUS_CODES,
244
238
  raise_scim_errors: bool = True,
245
239
  **kwargs,
246
- ) -> Union[AnyResource, Error, Dict]:
247
- """Perform a POST request to create, as defined in :rfc:`RFC7644 §3.3
248
- <7644#section-3.3>`.
240
+ ) -> Union[AnyResource, Error, dict]:
241
+ """Perform a POST request to create, as defined in :rfc:`RFC7644 §3.3 <7644#section-3.3>`.
249
242
 
250
243
  :param resource: The resource to create
251
244
  If is a :data:`dict`, the resource type will be guessed from the schema.
@@ -328,17 +321,16 @@ class SCIMClient:
328
321
 
329
322
  def query(
330
323
  self,
331
- resource_type: Optional[Type] = None,
324
+ resource_type: Optional[type] = None,
332
325
  id: Optional[str] = None,
333
- search_request: Optional[Union[SearchRequest, Dict]] = None,
326
+ search_request: Optional[Union[SearchRequest, dict]] = None,
334
327
  check_request_payload: bool = True,
335
328
  check_response_payload: bool = True,
336
- expected_status_codes: Optional[List[int]] = QUERY_RESPONSE_STATUS_CODES,
329
+ expected_status_codes: Optional[list[int]] = QUERY_RESPONSE_STATUS_CODES,
337
330
  raise_scim_errors: bool = True,
338
331
  **kwargs,
339
- ) -> Union[AnyResource, ListResponse[AnyResource], Error, Dict]:
340
- """Perform a GET request to read resources, as defined in :rfc:`RFC7644
341
- §3.4.2 <7644#section-3.4.2>`.
332
+ ) -> Union[AnyResource, ListResponse[AnyResource], Error, dict]:
333
+ """Perform a GET request to read resources, as defined in :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2>`.
342
334
 
343
335
  - If `id` is not :data:`None`, the resource with the exact id will be reached.
344
336
  - If `id` is :data:`None`, all the resources with the given type will be reached.
@@ -459,12 +451,11 @@ class SCIMClient:
459
451
  search_request: Optional[SearchRequest] = None,
460
452
  check_request_payload: bool = True,
461
453
  check_response_payload: bool = True,
462
- expected_status_codes: Optional[List[int]] = SEARCH_RESPONSE_STATUS_CODES,
454
+ expected_status_codes: Optional[list[int]] = SEARCH_RESPONSE_STATUS_CODES,
463
455
  raise_scim_errors: bool = True,
464
456
  **kwargs,
465
- ) -> Union[AnyResource, ListResponse[AnyResource], Error, Dict]:
466
- """Perform a POST search request to read all available resources, as
467
- defined in :rfc:`RFC7644 §3.4.3 <7644#section-3.4.3>`.
457
+ ) -> Union[AnyResource, ListResponse[AnyResource], Error, dict]:
458
+ """Perform a POST search request to read all available resources, as defined in :rfc:`RFC7644 §3.4.3 <7644#section-3.4.3>`.
468
459
 
469
460
  :param resource_types: Resource type or union of types expected
470
461
  to be read from the response.
@@ -536,15 +527,14 @@ class SCIMClient:
536
527
 
537
528
  def delete(
538
529
  self,
539
- resource_type: Type,
530
+ resource_type: type,
540
531
  id: str,
541
532
  check_response_payload: bool = True,
542
- expected_status_codes: Optional[List[int]] = DELETION_RESPONSE_STATUS_CODES,
533
+ expected_status_codes: Optional[list[int]] = DELETION_RESPONSE_STATUS_CODES,
543
534
  raise_scim_errors: bool = True,
544
535
  **kwargs,
545
- ) -> Optional[Union[Error, Dict]]:
546
- """Perform a DELETE request to create, as defined in :rfc:`RFC7644 §3.6
547
- <7644#section-3.6>`.
536
+ ) -> Optional[Union[Error, dict]]:
537
+ """Perform a DELETE request to create, as defined in :rfc:`RFC7644 §3.6 <7644#section-3.6>`.
548
538
 
549
539
  :param resource_type: The type of the resource to delete.
550
540
  :param id: The type id the resource to delete.
@@ -593,15 +583,14 @@ class SCIMClient:
593
583
 
594
584
  def replace(
595
585
  self,
596
- resource: Union[AnyResource, Dict],
586
+ resource: Union[AnyResource, dict],
597
587
  check_request_payload: bool = True,
598
588
  check_response_payload: bool = True,
599
- expected_status_codes: Optional[List[int]] = REPLACEMENT_RESPONSE_STATUS_CODES,
589
+ expected_status_codes: Optional[list[int]] = REPLACEMENT_RESPONSE_STATUS_CODES,
600
590
  raise_scim_errors: bool = True,
601
591
  **kwargs,
602
- ) -> Union[AnyResource, Error, Dict]:
603
- """Perform a PUT request to replace a resource, as defined in
604
- :rfc:`RFC7644 §3.5.1 <7644#section-3.5.1>`.
592
+ ) -> Union[AnyResource, Error, dict]:
593
+ """Perform a PUT request to replace a resource, as defined in :rfc:`RFC7644 §3.5.1 <7644#section-3.5.1>`.
605
594
 
606
595
  :param resource: The new resource to replace.
607
596
  If is a :data:`dict`, the resource type will be guessed from the schema.
@@ -630,8 +619,7 @@ class SCIMClient:
630
619
 
631
620
  user = scim.query(User, "my-used-id")
632
621
  user.display_name = "Fancy New Name"
633
- response = scim.update(user)
634
- # 'response' may be a User or an Error object
622
+ updated_user = scim.replace(user)
635
623
 
636
624
  .. tip::
637
625
 
@@ -692,6 +680,6 @@ class SCIMClient:
692
680
  )
693
681
 
694
682
  def modify(
695
- self, resource: Union[AnyResource, Dict], op: PatchOp, **kwargs
696
- ) -> Optional[Union[AnyResource, Dict]]:
683
+ self, resource: Union[AnyResource, dict], op: PatchOp, **kwargs
684
+ ) -> Optional[Union[AnyResource, dict]]:
697
685
  raise NotImplementedError()
scim2_client/errors.py CHANGED
@@ -25,7 +25,7 @@ class SCIMRequestError(SCIMClientError):
25
25
  class RequestNetworkError(SCIMRequestError):
26
26
  """Error raised when a network error happened during request.
27
27
 
28
- This error is raised when a :class:`httpx.RequestError` has been catched while performing a request.
28
+ This error is raised when a :class:`httpx.RequestError` has been caught while performing a request.
29
29
  The original :class:`~httpx.RequestError` is available with :attr:`~BaseException.__cause__`.
30
30
  """
31
31
 
@@ -35,29 +35,32 @@ class RequestNetworkError(SCIMRequestError):
35
35
 
36
36
 
37
37
  class RequestPayloadValidationError(SCIMRequestError):
38
- """Error raised when an invalid request payload has been passed to
39
- SCIMClient.
38
+ """Error raised when an invalid request payload has been passed to SCIMClient.
40
39
 
41
- This error is raised when a :class:`pydantic.ValidationError` has been catched
40
+ This error is raised when a :class:`pydantic.ValidationError` has been caught
42
41
  while validating the client request payload.
43
42
  The original :class:`~pydantic.ValidationError` is available with :attr:`~BaseException.__cause__`.
44
43
 
45
44
  .. code-block:: python
46
45
 
47
46
  try:
48
- scim.create({"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"], "active": "not-a-bool"})
47
+ scim.create(
48
+ {
49
+ "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
50
+ "active": "not-a-bool",
51
+ }
52
+ )
49
53
  except RequestPayloadValidationError as exc:
50
54
  print("Original validation error cause", exc.__cause__)
51
55
  """
52
56
 
53
57
  def __init__(self, *args, **kwargs):
54
- message = kwargs.pop("message", "Server response payload validation error")
58
+ message = kwargs.pop("message", "Server request payload validation error")
55
59
  super().__init__(message, *args, **kwargs)
56
60
 
57
61
 
58
62
  class SCIMResponseError(SCIMClientError):
59
- """Base exception for errors happening during response payload
60
- validation."""
63
+ """Base exception for errors happening during response payload validation."""
61
64
 
62
65
 
63
66
  class SCIMResponseErrorObject(SCIMResponseError):
@@ -75,8 +78,7 @@ class SCIMResponseErrorObject(SCIMResponseError):
75
78
 
76
79
 
77
80
  class UnexpectedStatusCode(SCIMResponseError):
78
- """Error raised when a server returned an unexpected status code for a
79
- given :class:`~scim2_models.Context`."""
81
+ """Error raised when a server returned an unexpected status code for a given :class:`~scim2_models.Context`."""
80
82
 
81
83
  def __init__(self, *args, **kwargs):
82
84
  message = kwargs.pop(
@@ -87,8 +89,7 @@ class UnexpectedStatusCode(SCIMResponseError):
87
89
 
88
90
 
89
91
  class UnexpectedContentType(SCIMResponseError):
90
- """Error raised when a server returned an unexpected `Content-Type` header
91
- in a response."""
92
+ """Error raised when a server returned an unexpected `Content-Type` header in a response."""
92
93
 
93
94
  def __init__(self, *args, **kwargs):
94
95
  content_type = kwargs["source"].headers.get("content-type", "")
@@ -105,10 +106,9 @@ class UnexpectedContentFormat(SCIMResponseError):
105
106
 
106
107
 
107
108
  class ResponsePayloadValidationError(SCIMResponseError):
108
- """Error raised when the server returned a payload that cannot be
109
- validated.
109
+ """Error raised when the server returned a payload that cannot be validated.
110
110
 
111
- This error is raised when a :class:`pydantic.ValidationError` has been catched
111
+ This error is raised when a :class:`pydantic.ValidationError` has been caught
112
112
  while validating the server response payload.
113
113
  The original :class:`~pydantic.ValidationError` is available with :attr:`~BaseException.__cause__`.
114
114
 
@@ -0,0 +1,291 @@
1
+ Metadata-Version: 2.3
2
+ Name: scim2-client
3
+ Version: 0.2.1
4
+ Summary: Pythonically build SCIM requests and parse SCIM responses
5
+ Project-URL: documentation, https://scim2-client.readthedocs.io
6
+ Project-URL: repository, https://github.com/python-scim/scim2-client
7
+ Project-URL: changelog, https://scim2-client.readthedocs.io/en/latest/changelog.html
8
+ Project-URL: funding, https://github.com/sponsors/python-scim
9
+ Author-email: Yaal Coop <contact@yaal.coop>
10
+ License: Apache License
11
+ Version 2.0, January 2004
12
+ http://www.apache.org/licenses/
13
+
14
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
15
+
16
+ 1. Definitions.
17
+
18
+ "License" shall mean the terms and conditions for use, reproduction,
19
+ and distribution as defined by Sections 1 through 9 of this document.
20
+
21
+ "Licensor" shall mean the copyright owner or entity authorized by
22
+ the copyright owner that is granting the License.
23
+
24
+ "Legal Entity" shall mean the union of the acting entity and all
25
+ other entities that control, are controlled by, or are under common
26
+ control with that entity. For the purposes of this definition,
27
+ "control" means (i) the power, direct or indirect, to cause the
28
+ direction or management of such entity, whether by contract or
29
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
30
+ outstanding shares, or (iii) beneficial ownership of such entity.
31
+
32
+ "You" (or "Your") shall mean an individual or Legal Entity
33
+ exercising permissions granted by this License.
34
+
35
+ "Source" form shall mean the preferred form for making modifications,
36
+ including but not limited to software source code, documentation
37
+ source, and configuration files.
38
+
39
+ "Object" form shall mean any form resulting from mechanical
40
+ transformation or translation of a Source form, including but
41
+ not limited to compiled object code, generated documentation,
42
+ and conversions to other media types.
43
+
44
+ "Work" shall mean the work of authorship, whether in Source or
45
+ Object form, made available under the License, as indicated by a
46
+ copyright notice that is included in or attached to the work
47
+ (an example is provided in the Appendix below).
48
+
49
+ "Derivative Works" shall mean any work, whether in Source or Object
50
+ form, that is based on (or derived from) the Work and for which the
51
+ editorial revisions, annotations, elaborations, or other modifications
52
+ represent, as a whole, an original work of authorship. For the purposes
53
+ of this License, Derivative Works shall not include works that remain
54
+ separable from, or merely link (or bind by name) to the interfaces of,
55
+ the Work and Derivative Works thereof.
56
+
57
+ "Contribution" shall mean any work of authorship, including
58
+ the original version of the Work and any modifications or additions
59
+ to that Work or Derivative Works thereof, that is intentionally
60
+ submitted to Licensor for inclusion in the Work by the copyright owner
61
+ or by an individual or Legal Entity authorized to submit on behalf of
62
+ the copyright owner. For the purposes of this definition, "submitted"
63
+ means any form of electronic, verbal, or written communication sent
64
+ to the Licensor or its representatives, including but not limited to
65
+ communication on electronic mailing lists, source code control systems,
66
+ and issue tracking systems that are managed by, or on behalf of, the
67
+ Licensor for the purpose of discussing and improving the Work, but
68
+ excluding communication that is conspicuously marked or otherwise
69
+ designated in writing by the copyright owner as "Not a Contribution."
70
+
71
+ "Contributor" shall mean Licensor and any individual or Legal Entity
72
+ on behalf of whom a Contribution has been received by Licensor and
73
+ subsequently incorporated within the Work.
74
+
75
+ 2. Grant of Copyright License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ copyright license to reproduce, prepare Derivative Works of,
79
+ publicly display, publicly perform, sublicense, and distribute the
80
+ Work and such Derivative Works in Source or Object form.
81
+
82
+ 3. Grant of Patent License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ (except as stated in this section) patent license to make, have made,
86
+ use, offer to sell, sell, import, and otherwise transfer the Work,
87
+ where such license applies only to those patent claims licensable
88
+ by such Contributor that are necessarily infringed by their
89
+ Contribution(s) alone or by combination of their Contribution(s)
90
+ with the Work to which such Contribution(s) was submitted. If You
91
+ institute patent litigation against any entity (including a
92
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
93
+ or a Contribution incorporated within the Work constitutes direct
94
+ or contributory patent infringement, then any patent licenses
95
+ granted to You under this License for that Work shall terminate
96
+ as of the date such litigation is filed.
97
+
98
+ 4. Redistribution. You may reproduce and distribute copies of the
99
+ Work or Derivative Works thereof in any medium, with or without
100
+ modifications, and in Source or Object form, provided that You
101
+ meet the following conditions:
102
+
103
+ (a) You must give any other recipients of the Work or
104
+ Derivative Works a copy of this License; and
105
+
106
+ (b) You must cause any modified files to carry prominent notices
107
+ stating that You changed the files; and
108
+
109
+ (c) You must retain, in the Source form of any Derivative Works
110
+ that You distribute, all copyright, patent, trademark, and
111
+ attribution notices from the Source form of the Work,
112
+ excluding those notices that do not pertain to any part of
113
+ the Derivative Works; and
114
+
115
+ (d) If the Work includes a "NOTICE" text file as part of its
116
+ distribution, then any Derivative Works that You distribute must
117
+ include a readable copy of the attribution notices contained
118
+ within such NOTICE file, excluding those notices that do not
119
+ pertain to any part of the Derivative Works, in at least one
120
+ of the following places: within a NOTICE text file distributed
121
+ as part of the Derivative Works; within the Source form or
122
+ documentation, if provided along with the Derivative Works; or,
123
+ within a display generated by the Derivative Works, if and
124
+ wherever such third-party notices normally appear. The contents
125
+ of the NOTICE file are for informational purposes only and
126
+ do not modify the License. You may add Your own attribution
127
+ notices within Derivative Works that You distribute, alongside
128
+ or as an addendum to the NOTICE text from the Work, provided
129
+ that such additional attribution notices cannot be construed
130
+ as modifying the License.
131
+
132
+ You may add Your own copyright statement to Your modifications and
133
+ may provide additional or different license terms and conditions
134
+ for use, reproduction, or distribution of Your modifications, or
135
+ for any such Derivative Works as a whole, provided Your use,
136
+ reproduction, and distribution of the Work otherwise complies with
137
+ the conditions stated in this License.
138
+
139
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
140
+ any Contribution intentionally submitted for inclusion in the Work
141
+ by You to the Licensor shall be under the terms and conditions of
142
+ this License, without any additional terms or conditions.
143
+ Notwithstanding the above, nothing herein shall supersede or modify
144
+ the terms of any separate license agreement you may have executed
145
+ with Licensor regarding such Contributions.
146
+
147
+ 6. Trademarks. This License does not grant permission to use the trade
148
+ names, trademarks, service marks, or product names of the Licensor,
149
+ except as required for reasonable and customary use in describing the
150
+ origin of the Work and reproducing the content of the NOTICE file.
151
+
152
+ 7. Disclaimer of Warranty. Unless required by applicable law or
153
+ agreed to in writing, Licensor provides the Work (and each
154
+ Contributor provides its Contributions) on an "AS IS" BASIS,
155
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
156
+ implied, including, without limitation, any warranties or conditions
157
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
158
+ PARTICULAR PURPOSE. You are solely responsible for determining the
159
+ appropriateness of using or redistributing the Work and assume any
160
+ risks associated with Your exercise of permissions under this License.
161
+
162
+ 8. Limitation of Liability. In no event and under no legal theory,
163
+ whether in tort (including negligence), contract, or otherwise,
164
+ unless required by applicable law (such as deliberate and grossly
165
+ negligent acts) or agreed to in writing, shall any Contributor be
166
+ liable to You for damages, including any direct, indirect, special,
167
+ incidental, or consequential damages of any character arising as a
168
+ result of this License or out of the use or inability to use the
169
+ Work (including but not limited to damages for loss of goodwill,
170
+ work stoppage, computer failure or malfunction, or any and all
171
+ other commercial damages or losses), even if such Contributor
172
+ has been advised of the possibility of such damages.
173
+
174
+ 9. Accepting Warranty or Additional Liability. While redistributing
175
+ the Work or Derivative Works thereof, You may choose to offer,
176
+ and charge a fee for, acceptance of support, warranty, indemnity,
177
+ or other liability obligations and/or rights consistent with this
178
+ License. However, in accepting such obligations, You may act only
179
+ on Your own behalf and on Your sole responsibility, not on behalf
180
+ of any other Contributor, and only if You agree to indemnify,
181
+ defend, and hold each Contributor harmless for any liability
182
+ incurred by, or claims asserted against, such Contributor by reason
183
+ of your accepting any such warranty or additional liability.
184
+
185
+ END OF TERMS AND CONDITIONS
186
+
187
+ APPENDIX: How to apply the Apache License to your work.
188
+
189
+ To apply the Apache License to your work, attach the following
190
+ boilerplate notice, with the fields enclosed by brackets "[]"
191
+ replaced with your own identifying information. (Don't include
192
+ the brackets!) The text should be enclosed in the appropriate
193
+ comment syntax for the file format. We also recommend that a
194
+ file or class name and description of purpose be included on the
195
+ same "printed page" as the copyright notice for easier
196
+ identification within third-party archives.
197
+
198
+ Copyright [yyyy] [name of copyright owner]
199
+
200
+ Licensed under the Apache License, Version 2.0 (the "License");
201
+ you may not use this file except in compliance with the License.
202
+ You may obtain a copy of the License at
203
+
204
+ http://www.apache.org/licenses/LICENSE-2.0
205
+
206
+ Unless required by applicable law or agreed to in writing, software
207
+ distributed under the License is distributed on an "AS IS" BASIS,
208
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
+ See the License for the specific language governing permissions and
210
+ limitations under the License.
211
+ License-File: LICENSE.md
212
+ Keywords: api,httpx,provisioning,rfc7643,rfc7644,scim,scim2
213
+ Classifier: Development Status :: 3 - Alpha
214
+ Classifier: Environment :: Web Environment
215
+ Classifier: Intended Audience :: Developers
216
+ Classifier: License :: OSI Approved :: Apache Software License
217
+ Classifier: Operating System :: OS Independent
218
+ Classifier: Programming Language :: Python
219
+ Classifier: Programming Language :: Python :: 3.9
220
+ Classifier: Programming Language :: Python :: 3.10
221
+ Classifier: Programming Language :: Python :: 3.11
222
+ Classifier: Programming Language :: Python :: 3.12
223
+ Classifier: Programming Language :: Python :: 3.13
224
+ Classifier: Programming Language :: Python :: Implementation :: CPython
225
+ Requires-Python: >=3.9
226
+ Requires-Dist: httpx>=0.24.0
227
+ Requires-Dist: scim2-models>=0.2.0
228
+ Description-Content-Type: text/markdown
229
+
230
+ # scim2-client
231
+
232
+ A SCIM client Python library built upon [scim2-models](https://scim2-models.readthedocs.io) and [httpx](https://github.com/encode/httpx),
233
+ that pythonically build requests and parse responses,
234
+ following the [RFC7643](https://datatracker.ietf.org/doc/html/rfc7643.html) and [RFC7644](https://datatracker.ietf.org/doc/html/rfc7644.html) specifications.
235
+
236
+ It aims to be used in SCIM client applications, or in unit tests for SCIM server applications.
237
+
238
+ ## What's SCIM anyway?
239
+
240
+ SCIM stands for System for Cross-domain Identity Management, and it is a provisioning protocol.
241
+ Provisioning is the action of managing a set of resources across different services, usually users and groups.
242
+ SCIM is often used between Identity Providers and applications in completion of standards like OAuth2 and OpenID Connect.
243
+ It allows users and groups creations, modifications and deletions to be synchronized between applications.
244
+
245
+ ## Installation
246
+
247
+ ```shell
248
+ pip install scim2-client
249
+ ```
250
+
251
+ ## Usage
252
+
253
+ Check the [tutorial](https://scim2-client.readthedocs.io/en/latest/tutorial.html) and the [reference](https://scim2-client.readthedocs.io/en/latest/reference.html) for more details.
254
+
255
+ Here is an example of usage:
256
+
257
+ ```python
258
+ import datetime
259
+ from httpx import Client
260
+ from scim2_models import User, EnterpriseUser, Group, Error
261
+ from scim2_client import SCIMClient
262
+
263
+ client = Client(base_url=f"https://auth.example/scim/v2", headers={"Authorization": "Bearer foobar"})
264
+ scim = SCIMClient(client, resource_types=(User[EnterpriseUser], Group))
265
+
266
+ # Query resources
267
+ user = scim.query(User[EnterpriseUser], "2819c223-7f76-453a-919d-413861904646")
268
+ assert user.user_name == "bjensen@example.com"
269
+ assert user.meta.last_updated == datetime.datetime(
270
+ 2024, 4, 13, 12, 0, 0, tzinfo=datetime.timezone.utc
271
+ )
272
+
273
+ # Update resources
274
+ user.display_name = "Babs Jensen"
275
+ user = scim.replace(user)
276
+ assert user.display_name == "Babs Jensen"
277
+ assert user.meta.last_updated == datetime.datetime(
278
+ 2024, 4, 13, 12, 0, 30, tzinfo=datetime.timezone.utc
279
+ )
280
+
281
+ # Create resources
282
+ payload = User(user_name="bjensen@example.com")
283
+ response = scim.create(user)
284
+ assert isinstance(response, Error)
285
+ assert response.detail == "One or more of the attribute values are already in use or are reserved."
286
+ ```
287
+
288
+ scim2-client belongs in a collection of SCIM tools developed by [Yaal Coop](https://yaal.coop),
289
+ with [scim2-models](https://github.com/python-scim/scim2-models),
290
+ [scim2-tester](https://github.com/python-scim/scim2-tester) and
291
+ [scim2-cli](https://github.com/python-scim/scim2-cli)
@@ -0,0 +1,7 @@
1
+ scim2_client/__init__.py,sha256=vgrTJZIqJLZc72XCJwYKrSCGUDkMZTJjCJiZkHERZGs,780
2
+ scim2_client/client.py,sha256=I3_CjI9njNbzOux6abwWkMYfT1q40SvnkQuYlifMdJQ,27107
3
+ scim2_client/errors.py,sha256=XH5e8zx3a1228GJjxugEgwO-shYAZWQx6LK_yZyX53E,4495
4
+ scim2_client-0.2.1.dist-info/METADATA,sha256=pGhr3ZzcA_O85rQsMfJ97vBdK9_FZehK5m2qZfceMhA,16767
5
+ scim2_client-0.2.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
6
+ scim2_client-0.2.1.dist-info/licenses/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
7
+ scim2_client-0.2.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: hatchling 1.25.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,88 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: scim2-client
3
- Version: 0.2.0
4
- Summary: Pythonically build SCIM requests and parse SCIM responses
5
- License: MIT
6
- Keywords: scim,scim2,provisioning,httpx,api
7
- Author: Yaal Coop
8
- Author-email: contact@yaal.coop
9
- Requires-Python: >=3.9,<4.0
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Environment :: Web Environment
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Operating System :: OS Independent
15
- Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.9
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Programming Language :: Python :: Implementation :: CPython
22
- Requires-Dist: httpx (>=0.24.0)
23
- Requires-Dist: scim2-models (>=0.2.0,<0.3.0)
24
- Description-Content-Type: text/markdown
25
-
26
- # scim2-client
27
-
28
- A SCIM client Python library built upon [scim2-models](https://scim2-models.readthedocs.io) and [httpx](https://github.com/encode/httpx),
29
- that pythonically build requests and parse responses,
30
- following the [RFC7643](https://datatracker.ietf.org/doc/html/rfc7643.html) and [RFC7644](https://datatracker.ietf.org/doc/html/rfc7644.html) specifications.
31
-
32
- It aims to be used in SCIM client applications, or in unit tests for SCIM server applications.
33
-
34
- ## What's SCIM anyway?
35
-
36
- SCIM stands for System for Cross-domain Identity Management, and it is a provisioning protocol.
37
- Provisioning is the action of managing a set of resources across different services, usually users and groups.
38
- SCIM is often used between Identity Providers and applications in completion of standards like OAuth2 and OpenID Connect.
39
- It allows users and groups creations, modifications and deletions to be synchronized between applications.
40
-
41
- ## Installation
42
-
43
- ```shell
44
- pip install scim2-client
45
- ```
46
-
47
- ## Usage
48
-
49
- Check the [tutorial](https://scim2-client.readthedocs.io/en/latest/tutorial.html) and the [reference](https://scim2-client.readthedocs.io/en/latest/reference.html) for more details.
50
-
51
- Here is an example of usage:
52
-
53
- ```python
54
- import datetime
55
- from httpx import Client
56
- from scim2_models import User, EnterpriseUser, Group, Error
57
- from scim2_client import SCIMClient
58
-
59
- client = Client(base_url=f"https://auth.example/scim/v2", headers={"Authorization": "Bearer foobar"})
60
- scim = SCIMClient(client, resource_types=(User[EnterpriseUser], Group))
61
-
62
- # Query resources
63
- user = scim.query(User[EnterpriseUser], "2819c223-7f76-453a-919d-413861904646")
64
- assert user.user_name == "bjensen@example.com"
65
- assert user.meta.last_updated == datetime.datetime(
66
- 2024, 4, 13, 12, 0, 0, tzinfo=datetime.timezone.utc
67
- )
68
-
69
- # Update resources
70
- user.display_name = "Babs Jensen"
71
- user = scim.replace(user)
72
- assert user.display_name == "Babs Jensen"
73
- assert user.meta.last_updated == datetime.datetime(
74
- 2024, 4, 13, 12, 0, 30, tzinfo=datetime.timezone.utc
75
- )
76
-
77
- # Create resources
78
- payload = User(user_name="bjensen@example.com")
79
- response = scim.create(user)
80
- assert isinstance(response, Error)
81
- assert response.detail == "One or more of the attribute values are already in use or are reserved."
82
- ```
83
-
84
- scim2-client belongs in a collection of SCIM tools developed by [Yaal Coop](https://yaal.coop),
85
- with [scim2-models](https://github.com/yaal-coop/scim2-models),
86
- [scim2-tester](https://github.com/yaal-coop/scim2-tester) and
87
- [scim2-cli](https://github.com/yaal-coop/scim2-cli)
88
-
@@ -1,6 +0,0 @@
1
- scim2_client/__init__.py,sha256=vgrTJZIqJLZc72XCJwYKrSCGUDkMZTJjCJiZkHERZGs,780
2
- scim2_client/client.py,sha256=hFcpUG2jYtNb5e178lsf4-SubXb0opO9JgegR6Q-JZQ,27278
3
- scim2_client/errors.py,sha256=Lu_4lPlbryqWYGLPmH2iWaVmlay8S4PrH6lUPIvcisA,4430
4
- scim2_client-0.2.0.dist-info/METADATA,sha256=b5Q_wytHLRpCPga0hwYTVKgMmX0o9mFXuStQYtzNf50,3497
5
- scim2_client-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
- scim2_client-0.2.0.dist-info/RECORD,,