-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy patherror.py
More file actions
113 lines (95 loc) · 6.06 KB
/
error.py
File metadata and controls
113 lines (95 loc) · 6.06 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
111
112
113
from typing import Annotated
from pydantic import PlainSerializer
from ..path import URN
from ..utils import _int_to_str
from .message import Message
class Error(Message):
"""Representation of SCIM API errors."""
__schema__ = URN("urn:ietf:params:scim:api:messages:2.0:Error")
status: Annotated[int | None, PlainSerializer(_int_to_str)] = None
"""The HTTP status code (see Section 6 of [RFC7231]) expressed as a JSON
string."""
scim_type: str | None = None
"""A SCIM detail error keyword."""
detail: str | None = None
"""A detailed human-readable message."""
@classmethod
def make_invalid_filter_error(cls) -> "Error":
"""Pre-defined error intended to be raised when the specified filter syntax was invalid (does not comply with :rfc:`Figure 1 of RFC7644 <7644#section-3.4.2.2>`), or the specified attribute and filter comparison combination is not supported."""
return Error(
status=400,
scim_type="invalidFilter",
detail="""The specified filter syntax was invalid (does not comply with Figure 1 of RFC7644), or the specified attribute and filter comparison combination is not supported.""",
)
@classmethod
def make_too_many_error(cls) -> "Error":
"""Pre-defined error intended to be raised when the specified filter yields many more results than the server is willing to calculate or process. For example, a filter such as ``(userName pr)`` by itself would return all entries with a ``userName`` and MAY not be acceptable to the service provider."""
return Error(
status=400,
scim_type="tooMany",
detail="""The specified filter yields many more results than the server is willing to calculate or process. For example, a filter such as "(userName pr)" by itself would return all entries with a "userName" and MAY not be acceptable to the service provider.""",
)
@classmethod
def make_uniqueness_error(cls) -> "Error":
"""Pre-defined error intended to be raised when One or more of the attribute values are already in use or are reserved."""
return Error(
status=409,
scim_type="uniqueness",
detail="""One or more of the attribute values are already in use or are reserved.""",
)
@classmethod
def make_mutability_error(cls) -> "Error":
"""Pre-defined error intended to be raised when the attempted modification is not compatible with the target attribute's mutability or current state (e.g., modification of an "immutable" attribute with an existing value)."""
return Error(
status=400,
scim_type="mutability",
detail="""The attempted modification is not compatible with the target attribute's mutability or current state (e.g., modification of an "immutable" attribute with an existing value).""",
)
@classmethod
def make_invalid_syntax_error(cls) -> "Error":
"""Pre-defined error intended to be raised when the request body message structure was invalid or did not conform to the request schema."""
return Error(
status=400,
scim_type="invalidSyntax",
detail="""The request body message structure was invalid or did not conform to the request schema.""",
)
@classmethod
def make_invalid_path_error(cls) -> "Error":
"""Pre-defined error intended to be raised when the "path" attribute was invalid or malformed (see :rfc:`Figure 7 of RFC7644 <7644#section-3.5.2>`)."""
return Error(
status=400,
scim_type="invalidPath",
detail="""The "path" attribute was invalid or malformed (see Figure 7 of RFC7644).""",
)
@classmethod
def make_no_target_error(cls) -> "Error":
"""Pre-defined error intended to be raised when the specified "path" did not yield an attribute or attribute value that could be operated on. This occurs when the specified "path" value contains a filter that yields no match."""
return Error(
status=400,
scim_type="noTarget",
detail="""The specified "path" did not yield an attribute or attribute value that could be operated on. This occurs when the specified "path" value contains a filter that yields no match.""",
)
@classmethod
def make_invalid_value_error(cls) -> "Error":
"""Pre-defined error intended to be raised when a required value was missing, or the value specified was not compatible with the operation or attribute type (see :rfc:`Section 2.2 of RFC7643 <7643#section-2.2>`), or resource schema (see :rfc:`Section 4 of RFC7643 <7643#section-4>`)."""
return Error(
status=400,
scim_type="invalidValue",
detail="""A required value was missing, or the value specified was not compatible with the operation or attribute type (see Section 2.2 of RFC7643), or resource schema (see Section 4 of RFC7643).""",
)
@classmethod
def make_invalid_version_error(cls) -> "Error":
"""Pre-defined error intended to be raised when the specified SCIM protocol version is not supported (see :rfc:`Section 3.13 of RFC7644 <7644#section-3.13>`)."""
return Error(
status=400,
scim_type="invalidVers",
detail="""The specified SCIM protocol version is not supported (see Section 3.13 of RFC7644).""",
)
@classmethod
def make_sensitive_error(cls) -> "Error":
"""Pre-defined error intended to be raised when the specified request cannot be completed, due to the passing of sensitive (e.g., personal) information in a request URI. For example, personal information SHALL NOT be transmitted over request URIs. See :rfc:`Section 7.5.2 of RFC7644 <7644#section-7.5.2>`."""
return Error(
status=400,
scim_type="sensitive",
detail="""The specified request cannot be completed, due to the passing of sensitive (e.g., personal) information in a request URI. For example, personal information SHALL NOT be transmitted over request URIs. See Section 7.5.2. of RFC7644""",
)