scim2-models 0.6.0__py3-none-any.whl → 0.6.2__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.
@@ -52,6 +52,21 @@ class SCIMException(Exception):
52
52
  {"scim_type": self.scim_type, "status": self.status, **self.context},
53
53
  )
54
54
 
55
+ @classmethod
56
+ def from_error(cls, error: "Error") -> "SCIMException":
57
+ """Create an exception from a SCIM Error object.
58
+
59
+ :param error: The SCIM Error object to convert.
60
+ :return: The appropriate SCIMException subclass instance.
61
+ """
62
+ from .messages.error import Error
63
+
64
+ if not isinstance(error, Error):
65
+ raise TypeError(f"Expected Error, got {type(error).__name__}")
66
+
67
+ exception_class = _SCIM_TYPE_TO_EXCEPTION.get(error.scim_type or "", cls)
68
+ return exception_class(detail=error.detail)
69
+
55
70
 
56
71
  class InvalidFilterException(SCIMException):
57
72
  """The specified filter syntax was invalid.
@@ -263,3 +278,17 @@ class SensitiveException(SCIMException):
263
278
  "The specified request cannot be completed, due to the passing of sensitive "
264
279
  "information in a request URI"
265
280
  )
281
+
282
+
283
+ _SCIM_TYPE_TO_EXCEPTION: dict[str, type[SCIMException]] = {
284
+ "invalidFilter": InvalidFilterException,
285
+ "tooMany": TooManyException,
286
+ "uniqueness": UniquenessException,
287
+ "mutability": MutabilityException,
288
+ "invalidSyntax": InvalidSyntaxException,
289
+ "invalidPath": InvalidPathException,
290
+ "noTarget": NoTargetException,
291
+ "invalidValue": InvalidValueException,
292
+ "invalidVers": InvalidVersionException,
293
+ "sensitive": SensitiveException,
294
+ }
scim2_models/path.py CHANGED
@@ -129,7 +129,9 @@ class Path(UserString, Generic[ResourceT]):
129
129
  serialization=core_schema.plain_serializer_function_ser_schema(str),
130
130
  )
131
131
 
132
- def __init__(self, path: str):
132
+ def __init__(self, path: "str | Path[Any]"):
133
+ if isinstance(path, Path):
134
+ path = str(path)
133
135
  self.check_syntax(path)
134
136
  self.data = path
135
137
 
@@ -386,8 +386,8 @@ class Resource(ScimObject, Generic[AnyExtension]):
386
386
  def _prepare_model_dump(
387
387
  self,
388
388
  scim_ctx: Context | None = Context.DEFAULT,
389
- attributes: list[str] | None = None,
390
- excluded_attributes: list[str] | None = None,
389
+ attributes: list[str | Path[Any]] | None = None,
390
+ excluded_attributes: list[str | Path[Any]] | None = None,
391
391
  **kwargs: Any,
392
392
  ) -> dict[str, Any]:
393
393
  kwargs = super()._prepare_model_dump(scim_ctx, **kwargs)
@@ -410,8 +410,8 @@ class Resource(ScimObject, Generic[AnyExtension]):
410
410
  self,
411
411
  *args: Any,
412
412
  scim_ctx: Context | None = Context.DEFAULT,
413
- attributes: list[str] | None = None,
414
- excluded_attributes: list[str] | None = None,
413
+ attributes: list[str | Path[Any]] | None = None,
414
+ excluded_attributes: list[str | Path[Any]] | None = None,
415
415
  **kwargs: Any,
416
416
  ) -> dict[str, Any]:
417
417
  """Create a model representation that can be included in SCIM messages by using Pydantic :code:`BaseModel.model_dump`.
@@ -436,8 +436,8 @@ class Resource(ScimObject, Generic[AnyExtension]):
436
436
  self,
437
437
  *args: Any,
438
438
  scim_ctx: Context | None = Context.DEFAULT,
439
- attributes: list[str] | None = None,
440
- excluded_attributes: list[str] | None = None,
439
+ attributes: list[str | Path[Any]] | None = None,
440
+ excluded_attributes: list[str | Path[Any]] | None = None,
441
441
  **kwargs: Any,
442
442
  ) -> str:
443
443
  """Create a JSON model representation that can be included in SCIM messages by using Pydantic :code:`BaseModel.model_dump_json`.
@@ -180,7 +180,7 @@ class Address(ComplexAttribute):
180
180
 
181
181
  primary: bool | None = None
182
182
  """A Boolean value indicating the 'primary' or preferred attribute value
183
- for this attribute, e.g., the preferred photo or thumbnail."""
183
+ for this attribute, e.g., the preferred address."""
184
184
 
185
185
 
186
186
  class Entitlement(ComplexAttribute):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: scim2-models
3
- Version: 0.6.0
3
+ Version: 0.6.2
4
4
  Summary: SCIM2 models serialization and validation with pydantic
5
5
  Keywords: scim,scim2,provisioning,pydantic,rfc7643,rfc7644
6
6
  Author: Yaal Coop
@@ -4,7 +4,7 @@ scim2_models/attributes.py,sha256=v_bjJSdBmPlGh20W2Y57PIZnqvMTYHQyJuJLfQjGmwc,18
4
4
  scim2_models/base.py,sha256=dB0idU8apEwPwJpax1EWYX-omxcIy9Z4DMjNhrwTJAg,22407
5
5
  scim2_models/constants.py,sha256=9egq8JW0dFAqPng85CiHoH5T6pRtYL87-gC0C-IMGsk,573
6
6
  scim2_models/context.py,sha256=RjgMIvWPr8f41qbVL1sjaDnm9GRKyrCrgfC4npwwcMg,9149
7
- scim2_models/exceptions.py,sha256=0rvJTRM3CbaB2-T_PAhii5W-YEvTY31scPdrauGJi0M,7655
7
+ scim2_models/exceptions.py,sha256=_LbknoZrCrCaL7tKYrRF_G0vtru56OYrrqBARySAVXk,8684
8
8
  scim2_models/messages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  scim2_models/messages/bulk.py,sha256=fWm9s88FHa66Aa0XeLcN7HurHp98JhlqM1rkEnIKZ8A,2429
10
10
  scim2_models/messages/error.py,sha256=gbHxf47ZIamnZAgD7cNAwHXxEZsf36PTdtcejesYIy0,12138
@@ -12,19 +12,19 @@ scim2_models/messages/list_response.py,sha256=ahAqdElGSNxt8LlOUeSsNbOykZdCLM4aJy
12
12
  scim2_models/messages/message.py,sha256=7svNN_xi8BSyWmRoMdYFTjQGuV1F9HUpQYHb6TQtf8A,4081
13
13
  scim2_models/messages/patch_op.py,sha256=QwAkeHvzzUXFmS8Ut_ns99yhiSQehpuHAodI_eSc_hA,16236
14
14
  scim2_models/messages/search_request.py,sha256=OXw4-oehLC5NyD7yVFEq0QgPsxAaQwXE7hZMKiNkvzY,3017
15
- scim2_models/path.py,sha256=uEt6d-ebHH9aJTizzXDDOJknVA7CbEe8YVQa6x8JEqE,26975
15
+ scim2_models/path.py,sha256=4u-Lqtq8lqSmJUi6thFDwhpzc-uzyVFulsTklIyIFL8,27053
16
16
  scim2_models/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  scim2_models/reference.py,sha256=-E6VD-lFPEIXpSpwu0G_3MKLbWKgZhwk8ER3-JhCHig,5636
18
18
  scim2_models/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  scim2_models/resources/enterprise_user.py,sha256=Wk8CzQrCXUE-roQYINpj4YhOlj2s_TD3Y3SnEXK6jKY,1798
20
20
  scim2_models/resources/group.py,sha256=nmmPlbP7gQluNJEtFIFYtjDYJ2AR4Uml5LuxMcY_NIk,1379
21
- scim2_models/resources/resource.py,sha256=nzwb_ZjW2xx22gSyXhyrEcrKFvhD7y9RrzaN610Rbyo,20478
21
+ scim2_models/resources/resource.py,sha256=0Y8xloQk6tWQ9L7gW__qlUkU55mpYAsxfpeuFuSX2Vk,20550
22
22
  scim2_models/resources/resource_type.py,sha256=IDzUcv9_XiAHOpaaG9j24sa-nNKY6i0wPDTTrxNqJgQ,3297
23
23
  scim2_models/resources/schema.py,sha256=wDh8G1oxCgyQcmChz30bVNPjyksYcgxD66k0mB1VIdI,10239
24
24
  scim2_models/resources/service_provider_config.py,sha256=cmfPtLPOuwNrZl9hGpbrMsQhoOwIytlf2Q_LAJegAcQ,5303
25
- scim2_models/resources/user.py,sha256=ZvyjxZiF52d_L_LUCEZpec6CXOe40_udZhOHpjzFpxs,11409
25
+ scim2_models/resources/user.py,sha256=Z-h8x9dAnxBqDeZJbKi-u-HCv6aQdS8e4VzHLVm63ZA,11398
26
26
  scim2_models/scim_object.py,sha256=suYhQ0iFQs1aKTlSerWZsi_sAVhFX_9N24U_DmZxCbw,5321
27
27
  scim2_models/utils.py,sha256=Lb7mlP3I_IfAlqi_8_m4G-_1Rn7oKRqbNdpoDLjXXr0,1978
28
- scim2_models-0.6.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
29
- scim2_models-0.6.0.dist-info/METADATA,sha256=ZCHD84CvfCgyOaTYiKvbfx5EisWpuqd0JhahCxW9_go,16486
30
- scim2_models-0.6.0.dist-info/RECORD,,
28
+ scim2_models-0.6.2.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
29
+ scim2_models-0.6.2.dist-info/METADATA,sha256=q6LTJlB0nesIAO3-DP7Exy2cw4IbODc8MxGRTydt7Qw,16486
30
+ scim2_models-0.6.2.dist-info/RECORD,,