scim2-models 0.3.6__py3-none-any.whl → 0.3.7__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_models/__init__.py +11 -11
- scim2_models/annotations.py +104 -0
- scim2_models/attributes.py +57 -0
- scim2_models/base.py +68 -525
- scim2_models/constants.py +3 -3
- scim2_models/context.py +168 -0
- scim2_models/reference.py +82 -0
- scim2_models/rfc7643/enterprise_user.py +4 -4
- scim2_models/rfc7643/group.py +5 -5
- scim2_models/rfc7643/resource.py +202 -95
- scim2_models/rfc7643/resource_type.py +13 -22
- scim2_models/rfc7643/schema.py +44 -38
- scim2_models/rfc7643/service_provider_config.py +7 -7
- scim2_models/rfc7643/user.py +9 -9
- scim2_models/rfc7644/bulk.py +2 -2
- scim2_models/rfc7644/error.py +11 -11
- scim2_models/rfc7644/list_response.py +5 -66
- scim2_models/rfc7644/message.py +103 -3
- scim2_models/rfc7644/patch_op.py +20 -6
- scim2_models/rfc7644/search_request.py +4 -4
- scim2_models/scim_object.py +143 -0
- scim2_models/utils.py +1 -1
- {scim2_models-0.3.6.dist-info → scim2_models-0.3.7.dist-info}/METADATA +1 -1
- scim2_models-0.3.7.dist-info/RECORD +29 -0
- scim2_models-0.3.6.dist-info/RECORD +0 -24
- {scim2_models-0.3.6.dist-info → scim2_models-0.3.7.dist-info}/WHEEL +0 -0
- {scim2_models-0.3.6.dist-info → scim2_models-0.3.7.dist-info}/licenses/LICENSE +0 -0
scim2_models/__init__.py
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
from .annotations import CaseExact
|
|
2
|
+
from .annotations import Mutability
|
|
3
|
+
from .annotations import Required
|
|
4
|
+
from .annotations import Returned
|
|
5
|
+
from .annotations import Uniqueness
|
|
6
|
+
from .attributes import ComplexAttribute
|
|
7
|
+
from .attributes import MultiValuedComplexAttribute
|
|
1
8
|
from .base import BaseModel
|
|
2
|
-
from .
|
|
3
|
-
from .
|
|
4
|
-
from .
|
|
5
|
-
from .
|
|
6
|
-
from .base import MultiValuedComplexAttribute
|
|
7
|
-
from .base import Mutability
|
|
8
|
-
from .base import Reference
|
|
9
|
-
from .base import Required
|
|
10
|
-
from .base import Returned
|
|
11
|
-
from .base import Uniqueness
|
|
12
|
-
from .base import URIReference
|
|
9
|
+
from .context import Context
|
|
10
|
+
from .reference import ExternalReference
|
|
11
|
+
from .reference import Reference
|
|
12
|
+
from .reference import URIReference
|
|
13
13
|
from .rfc7643.enterprise_user import EnterpriseUser
|
|
14
14
|
from .rfc7643.enterprise_user import Manager
|
|
15
15
|
from .rfc7643.group import Group
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Mutability(str, Enum):
|
|
5
|
+
"""A single keyword indicating the circumstances under which the value of the attribute can be (re)defined."""
|
|
6
|
+
|
|
7
|
+
read_only = "readOnly"
|
|
8
|
+
"""The attribute SHALL NOT be modified."""
|
|
9
|
+
|
|
10
|
+
read_write = "readWrite"
|
|
11
|
+
"""The attribute MAY be updated and read at any time."""
|
|
12
|
+
|
|
13
|
+
immutable = "immutable"
|
|
14
|
+
"""The attribute MAY be defined at resource creation (e.g., POST) or at
|
|
15
|
+
record replacement via a request (e.g., a PUT).
|
|
16
|
+
|
|
17
|
+
The attribute SHALL NOT be updated.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
write_only = "writeOnly"
|
|
21
|
+
"""The attribute MAY be updated at any time.
|
|
22
|
+
|
|
23
|
+
Attribute values SHALL NOT be returned (e.g., because the value is a
|
|
24
|
+
stored hash). Note: An attribute with a mutability of "writeOnly"
|
|
25
|
+
usually also has a returned setting of "never".
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
_default = read_write
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Returned(str, Enum):
|
|
32
|
+
"""A single keyword that indicates when an attribute and associated values are returned in response to a GET request or in response to a PUT, POST, or PATCH request."""
|
|
33
|
+
|
|
34
|
+
always = "always" # cannot be excluded
|
|
35
|
+
"""The attribute is always returned, regardless of the contents of the
|
|
36
|
+
"attributes" parameter.
|
|
37
|
+
|
|
38
|
+
For example, "id" is always returned to identify a SCIM resource.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
never = "never" # always excluded
|
|
42
|
+
"""The attribute is never returned, regardless of the contents of the
|
|
43
|
+
"attributes" parameter."""
|
|
44
|
+
|
|
45
|
+
default = "default" # included by default but can be excluded
|
|
46
|
+
"""The attribute is returned by default in all SCIM operation responses
|
|
47
|
+
where attribute values are returned, unless it is explicitly excluded."""
|
|
48
|
+
|
|
49
|
+
request = "request" # excluded by default but can be included
|
|
50
|
+
"""The attribute is returned in response to any PUT, POST, or PATCH
|
|
51
|
+
operations if specified in the "attributes" parameter."""
|
|
52
|
+
|
|
53
|
+
_default = default
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Uniqueness(str, Enum):
|
|
57
|
+
"""A single keyword value that specifies how the service provider enforces uniqueness of attribute values."""
|
|
58
|
+
|
|
59
|
+
none = "none"
|
|
60
|
+
"""The values are not intended to be unique in any way."""
|
|
61
|
+
|
|
62
|
+
server = "server"
|
|
63
|
+
"""The value SHOULD be unique within the context of the current SCIM
|
|
64
|
+
endpoint (or tenancy) and MAY be globally unique (e.g., a "username", email
|
|
65
|
+
address, or other server-generated key or counter).
|
|
66
|
+
|
|
67
|
+
No two resources on the same server SHOULD possess the same value.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
global_ = "global"
|
|
71
|
+
"""The value SHOULD be globally unique (e.g., an email address, a GUID, or
|
|
72
|
+
other value).
|
|
73
|
+
|
|
74
|
+
No two resources on any server SHOULD possess the same value.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
_default = none
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class Required(Enum):
|
|
81
|
+
"""A Boolean value that specifies whether the attribute is required or not.
|
|
82
|
+
|
|
83
|
+
Missing required attributes raise a :class:`~pydantic.ValidationError` on :attr:`~scim2_models.Context.RESOURCE_CREATION_REQUEST` and :attr:`~scim2_models.Context.RESOURCE_REPLACEMENT_REQUEST` validations.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
true = True
|
|
87
|
+
false = False
|
|
88
|
+
|
|
89
|
+
_default = false
|
|
90
|
+
|
|
91
|
+
def __bool__(self) -> bool:
|
|
92
|
+
return self.value
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class CaseExact(Enum):
|
|
96
|
+
"""A Boolean value that specifies whether a string attribute is case- sensitive or not."""
|
|
97
|
+
|
|
98
|
+
true = True
|
|
99
|
+
false = False
|
|
100
|
+
|
|
101
|
+
_default = false
|
|
102
|
+
|
|
103
|
+
def __bool__(self) -> bool:
|
|
104
|
+
return self.value
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from inspect import isclass
|
|
2
|
+
from typing import Annotated
|
|
3
|
+
from typing import Any
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from typing import get_origin
|
|
6
|
+
|
|
7
|
+
from pydantic import Field
|
|
8
|
+
|
|
9
|
+
from .annotations import Mutability
|
|
10
|
+
|
|
11
|
+
# This import will work because we'll import this module after BaseModel is defined
|
|
12
|
+
from .base import BaseModel
|
|
13
|
+
from .reference import Reference
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ComplexAttribute(BaseModel):
|
|
17
|
+
"""A complex attribute as defined in :rfc:`RFC7643 §2.3.8 <7643#section-2.3.8>`."""
|
|
18
|
+
|
|
19
|
+
attribute_urn: Optional[str] = Field(None, exclude=True)
|
|
20
|
+
|
|
21
|
+
def get_attribute_urn(self, field_name: str) -> str:
|
|
22
|
+
"""Build the full URN of the attribute.
|
|
23
|
+
|
|
24
|
+
See :rfc:`RFC7644 §3.10 <7644#section-3.10>`.
|
|
25
|
+
"""
|
|
26
|
+
alias = (
|
|
27
|
+
self.__class__.model_fields[field_name].serialization_alias or field_name
|
|
28
|
+
)
|
|
29
|
+
return f"{self.attribute_urn}.{alias}"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MultiValuedComplexAttribute(ComplexAttribute):
|
|
33
|
+
type: Optional[str] = None
|
|
34
|
+
"""A label indicating the attribute's function."""
|
|
35
|
+
|
|
36
|
+
primary: Optional[bool] = None
|
|
37
|
+
"""A Boolean value indicating the 'primary' or preferred attribute value
|
|
38
|
+
for this attribute."""
|
|
39
|
+
|
|
40
|
+
display: Annotated[Optional[str], Mutability.immutable] = None
|
|
41
|
+
"""A human-readable name, primarily used for display purposes."""
|
|
42
|
+
|
|
43
|
+
value: Optional[Any] = None
|
|
44
|
+
"""The value of an entitlement."""
|
|
45
|
+
|
|
46
|
+
ref: Optional[Reference] = Field(None, serialization_alias="$ref")
|
|
47
|
+
"""The reference URI of a target resource, if the attribute is a
|
|
48
|
+
reference."""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def is_complex_attribute(type_: type) -> bool:
|
|
52
|
+
# issubclass raise a TypeError with 'Reference' on python < 3.11
|
|
53
|
+
return (
|
|
54
|
+
get_origin(type_) != Reference
|
|
55
|
+
and isclass(type_)
|
|
56
|
+
and issubclass(type_, (ComplexAttribute, MultiValuedComplexAttribute))
|
|
57
|
+
)
|