Skip to content

Commit 31129ce

Browse files
committed
refactor: move model type classes inside the models
1 parent 9730234 commit 31129ce

File tree

5 files changed

+82
-101
lines changed

5 files changed

+82
-101
lines changed

pydantic_scim2/__init__.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
from .responses import PatchOperation
1212
from .responses import PatchRequest
1313
from .responses import SCIMError
14-
from .schema import AttributeKind
14+
from .schema import Attribute
1515
from .schema import Mutability
1616
from .schema import Returned
1717
from .schema import Schema
1818
from .schema import Uniqueness
1919
from .service_provider import AuthenticationScheme
20-
from .service_provider import AuthenticationSchemeKind
2120
from .service_provider import Bulk
2221
from .service_provider import ChangePassword
2322
from .service_provider import ETag
@@ -26,28 +25,23 @@
2625
from .service_provider import ServiceProviderConfiguration
2726
from .service_provider import Sort
2827
from .user import Address
29-
from .user import AddressKind
3028
from .user import Email
31-
from .user import EmailKind
3229
from .user import Entitlement
3330
from .user import Im
34-
from .user import ImKind
3531
from .user import Name
3632
from .user import PhoneNumber
37-
from .user import PhoneNumberKind
3833
from .user import Photo
39-
from .user import PhotoKind
4034
from .user import Role
4135
from .user import User
4236
from .user import X509Certificate
4337

4438
__all__ = [
4539
"Manager",
4640
"EnterpriseUser",
41+
"Attribute",
4742
"Group",
4843
"GroupMember",
4944
"SchemaExtension",
50-
"ResourceType",
5145
"SCIMError",
5246
"PatchOp",
5347
"PatchOperation",
@@ -59,18 +53,12 @@
5953
"ChangePassword",
6054
"Sort",
6155
"AuthenticationScheme",
62-
"AuthenticationSchemeKind",
6356
"ServiceProviderConfiguration",
6457
"Name",
65-
"EmailKind",
6658
"Email",
67-
"PhoneNumberKind",
6859
"PhoneNumber",
69-
"ImKind",
7060
"Im",
71-
"PhotoKind",
7261
"Photo",
73-
"AddressKind",
7462
"Address",
7563
"Entitlement",
7664
"Role",
@@ -80,8 +68,8 @@
8068
"Meta",
8169
"ETag",
8270
"Schema",
83-
"AttributeKind",
8471
"Mutability",
8572
"Returned",
8673
"Uniqueness",
74+
"ResourceType",
8775
]

pydantic_scim2/schema.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@
66
from .resource import Meta
77

88

9-
class AttributeKind(str, Enum):
10-
string = "string"
11-
boolean = "boolean"
12-
decimal = "decimal"
13-
integer = "integer"
14-
date_time = "dateTime"
15-
reference = "reference"
16-
binary = "binary"
17-
complex = "complex"
18-
19-
209
class Mutability(str, Enum):
2110
read_only = "readOnly"
2211
read_write = "readWrite"
@@ -38,10 +27,20 @@ class Uniqueness(str, Enum):
3827

3928

4029
class Attribute(SCIM2Model):
30+
class Type(str, Enum):
31+
string = "string"
32+
boolean = "boolean"
33+
decimal = "decimal"
34+
integer = "integer"
35+
date_time = "dateTime"
36+
reference = "reference"
37+
binary = "binary"
38+
complex = "complex"
39+
4140
name: str
4241
"""The attribute's name."""
4342

44-
type: AttributeKind
43+
type: Type
4544
"""The attribute's data type."""
4645

4746
sub_attributes: Optional[List["Attribute"]] = None

pydantic_scim2/service_provider.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,15 @@ class ETag(SCIM2Model):
5959
"""A Boolean value specifying whether or not the operation is supported."""
6060

6161

62-
class AuthenticationSchemeKind(str, Enum):
63-
oauth = "oauth"
64-
oauth2 = "oauth2"
65-
oauthbearertoken = "oauthbearertoken"
66-
httpbasic = "httpbasic"
67-
httpdigest = "httpdigest"
68-
69-
7062
class AuthenticationScheme(SCIM2Model):
71-
type: AuthenticationSchemeKind
63+
class Type(str, Enum):
64+
oauth = "oauth"
65+
oauth2 = "oauth2"
66+
oauthbearertoken = "oauthbearertoken"
67+
httpbasic = "httpbasic"
68+
httpdigest = "httpdigest"
69+
70+
type: Type
7271
"""The authentication scheme."""
7372

7473
name: str = Field(

pydantic_scim2/user.py

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ class Name(SCIM2Model):
3838
)
3939

4040

41-
class EmailKind(str, Enum):
42-
work = "work"
43-
home = "home"
44-
other = "other"
45-
46-
4741
class Email(SCIM2Model):
42+
class Type(str, Enum):
43+
work = "work"
44+
home = "home"
45+
other = "other"
46+
4847
value: Optional[EmailStr] = Field(
4948
None,
5049
description="Email addresses for the user. The value SHOULD be canonicalized by the service provider, e.g., '[email protected]' instead of '[email protected]'. Canonical type values of 'work', 'home', and 'other'.",
@@ -53,7 +52,7 @@ class Email(SCIM2Model):
5352
None,
5453
description="A human-readable name, primarily used for display purposes. READ-ONLY.",
5554
)
56-
type: Optional[EmailKind] = Field(
55+
type: Optional[Type] = Field(
5756
None,
5857
description="A label indicating the attribute's function, e.g., 'work' or 'home'.",
5958
)
@@ -63,22 +62,21 @@ class Email(SCIM2Model):
6362
)
6463

6564

66-
class PhoneNumberKind(str, Enum):
67-
work = "work"
68-
home = "home"
69-
mobile = "mobile"
70-
fax = "fax"
71-
pager = "pager"
72-
other = "other"
73-
74-
7565
class PhoneNumber(SCIM2Model):
66+
class Type(str, Enum):
67+
work = "work"
68+
home = "home"
69+
mobile = "mobile"
70+
fax = "fax"
71+
pager = "pager"
72+
other = "other"
73+
7674
value: Optional[str] = Field(None, description="Phone number of the User.")
7775
display: Optional[str] = Field(
7876
None,
7977
description="A human-readable name, primarily used for display purposes. READ-ONLY.",
8078
)
81-
type: Optional[PhoneNumberKind] = Field(
79+
type: Optional[Type] = Field(
8280
None,
8381
description="A label indicating the attribute's function, e.g., 'work', 'home', 'mobile'.",
8482
)
@@ -88,26 +86,25 @@ class PhoneNumber(SCIM2Model):
8886
)
8987

9088

91-
class ImKind(str, Enum):
92-
aim = "aim"
93-
gtalk = "gtalk"
94-
icq = "icq"
95-
xmpp = "xmpp"
96-
msn = "msn"
97-
skype = "skype"
98-
qq = "qq"
99-
yahoo = "yahoo"
100-
101-
10289
class Im(SCIM2Model):
90+
class Type(str, Enum):
91+
aim = "aim"
92+
gtalk = "gtalk"
93+
icq = "icq"
94+
xmpp = "xmpp"
95+
msn = "msn"
96+
skype = "skype"
97+
qq = "qq"
98+
yahoo = "yahoo"
99+
103100
value: Optional[str] = Field(
104101
None, description="Instant messaging address for the User."
105102
)
106103
display: Optional[str] = Field(
107104
None,
108105
description="A human-readable name, primarily used for display purposes. READ-ONLY.",
109106
)
110-
type: Optional[ImKind] = Field(
107+
type: Optional[Type] = Field(
111108
None,
112109
description="A label indicating the attribute's function, e.g., 'aim', 'gtalk', 'xmpp'.",
113110
)
@@ -117,18 +114,17 @@ class Im(SCIM2Model):
117114
)
118115

119116

120-
class PhotoKind(str, Enum):
121-
photo = "photo"
122-
thumbnail = "thumbnail"
123-
124-
125117
class Photo(SCIM2Model):
118+
class Type(str, Enum):
119+
photo = "photo"
120+
thumbnail = "thumbnail"
121+
126122
value: Optional[AnyUrl] = Field(None, description="URL of a photo of the User.")
127123
display: Optional[str] = Field(
128124
None,
129125
description="A human-readable name, primarily used for display purposes. READ-ONLY.",
130126
)
131-
type: Optional[PhotoKind] = Field(
127+
type: Optional[Type] = Field(
132128
None,
133129
description="A label indicating the attribute's function, i.e., 'photo' or 'thumbnail'.",
134130
)
@@ -138,13 +134,12 @@ class Photo(SCIM2Model):
138134
)
139135

140136

141-
class AddressKind(str, Enum):
142-
work = "work"
143-
home = "home"
144-
other = "other"
145-
146-
147137
class Address(SCIM2Model):
138+
class Type(str, Enum):
139+
work = "work"
140+
home = "home"
141+
other = "other"
142+
148143
formatted: Optional[str] = Field(
149144
None,
150145
description="The full mailing address, formatted for display or use with a mailing label. This attribute MAY contain newlines.",
@@ -159,7 +154,7 @@ class Address(SCIM2Model):
159154
None, description="The zip code or postal code component."
160155
)
161156
country: Optional[str] = Field(None, description="The country name component.")
162-
type: Optional[AddressKind] = Field(
157+
type: Optional[Type] = Field(
163158
None,
164159
description="A label indicating the attribute's function, e.g., 'work' or 'home'.",
165160
)

0 commit comments

Comments
 (0)