-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.py
More file actions
110 lines (78 loc) · 2.89 KB
/
schema.py
File metadata and controls
110 lines (78 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"""ldap schema schema.
Copyright (c) 2025 MultiFactor
License: https://github.com/MultiDirectoryLab/MultiDirectory/blob/main/LICENSE
"""
from typing import Generic, TypeVar
from pydantic import BaseModel, Field
from enums import EntityTypeNames, KindType
from ldap_protocol.ldap_schema.constants import (
DEFAULT_ENTITY_TYPE_IS_SYSTEM,
OID_REGEX_PATTERN,
)
from ldap_protocol.utils.pagination import BasePaginationSchema
_IdT = TypeVar("_IdT", int, None)
class AttributeTypeSchema(BaseModel, Generic[_IdT]):
"""Attribute Type Schema."""
id: _IdT = Field(default=None) # type: ignore[assignment]
oid: str = Field(pattern=OID_REGEX_PATTERN, max_length=128)
name: str = Field(min_length=1, max_length=255)
syntax: str
single_value: bool
no_user_modification: bool
is_system: bool
system_flags: int = 0
is_included_anr: bool = False
object_class_names: list[str] = Field(default_factory=list)
class AttributeTypeUpdateSchema(BaseModel):
"""Attribute Type Schema for modify/update."""
syntax: str
single_value: bool
no_user_modification: bool
is_included_anr: bool
class AttributeTypePaginationSchema(
BasePaginationSchema[AttributeTypeSchema[int]],
):
"""Attribute Type Schema with pagination result."""
items: list[AttributeTypeSchema[int]]
class ObjectClassSchema(BaseModel, Generic[_IdT]):
"""Object Class Request Schema."""
id: _IdT = Field(default=None) # type: ignore[assignment]
oid: str = Field(pattern=OID_REGEX_PATTERN, max_length=128)
name: str = Field(min_length=1, max_length=255)
superior_name: str | None
kind: KindType
attribute_type_names_must: list[str]
attribute_type_names_may: list[str]
is_system: bool = False
entity_type_names: set[str] = Field(default_factory=set)
class ObjectClassPaginationSchema(
BasePaginationSchema[ObjectClassSchema[int]],
):
"""Object Class Schema with pagination result."""
items: list[ObjectClassSchema[int]]
class ObjectClassUpdateSchema(BaseModel):
"""Object Class Schema for modify/update."""
attribute_type_names_must: list[str]
attribute_type_names_may: list[str]
class EntityTypeSchema(BaseModel, Generic[_IdT]):
"""Entity Type Schema."""
id: _IdT = Field(default=None) # type: ignore[assignment]
name: EntityTypeNames | str
is_system: bool
object_class_names: list[str] = Field(
default_factory=list,
min_length=1,
max_length=10000,
)
class EntityTypeUpdateSchema(BaseModel):
"""Entity Type Schema for modify/update."""
is_system: bool = DEFAULT_ENTITY_TYPE_IS_SYSTEM
name: str
object_class_names: list[str] = Field(
default_factory=list,
min_length=1,
max_length=10000,
)
class EntityTypePaginationSchema(BasePaginationSchema[EntityTypeSchema]):
"""Entity Type Schema with pagination result."""
items: list[EntityTypeSchema]