Skip to content

Commit

Permalink
doc: fix pre-defined errors documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Sep 1, 2024
1 parent 3e9f7fc commit 3844dbf
Showing 1 changed file with 107 additions and 91 deletions.
198 changes: 107 additions & 91 deletions scim2_models/rfc7644/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,97 +9,7 @@


class Error(Message):
"""Representation of SCIM API errors.
Here is the exhaustive list of pre-defined errors:
.. py:data:: pydanti_scim2.InvalidFilterError
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.
.. py:data:: pydanti_scim2.TooManyError
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.
.. py:data:: pydanti_scim2.UniquenessError
One or more of the attribute
values are already in use or
are reserved.
.. py:data:: pydanti_scim2.MutabilityError
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).
.. py:data:: pydanti_scim2.InvalidSyntaxError
The request body message
structure was invalid or did
not conform to the request
schema.
.. py:data:: pydanti_scim2.InvalidPathError
The "path" attribute was
invalid or malformed (see
:rfc:`Figure 7 of RFC7644 <7644#section-3.5.2>`).
.. py:data:: pydanti_scim2.NoTargetError
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.
.. py:data:: pydanti_scim2.InvalidValueError
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>`).
.. py:data:: pydanti_scim2.InvalidVersionError
The specified SCIM protocol
version is not supported (see
:rfc:`Section 3.13 of RFC7644 <7644#section-3.13>`).
.. py:data:: pydanti_scim2.SensitiveError
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>`.
"""
"""Representation of SCIM API errors."""

schemas: List[str] = ["urn:ietf:params:scim:api:messages:2.0:Error"]

Expand All @@ -115,6 +25,16 @@ class Error(Message):

@classmethod
def make_invalid_filter_error(cls):
"""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",
Expand All @@ -123,6 +43,20 @@ def make_invalid_filter_error(cls):

@classmethod
def make_too_many_error(cls):
"""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",
Expand All @@ -131,6 +65,14 @@ def make_too_many_error(cls):

@classmethod
def make_uniqueness_error(cls):
"""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",
Expand All @@ -139,6 +81,18 @@ def make_uniqueness_error(cls):

@classmethod
def make_mutability_error(cls):
"""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",
Expand All @@ -147,6 +101,15 @@ def make_mutability_error(cls):

@classmethod
def make_invalid_syntax_error(cls):
"""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",
Expand All @@ -155,6 +118,14 @@ def make_invalid_syntax_error(cls):

@classmethod
def make_invalid_path_error(cls):
"""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",
Expand All @@ -163,6 +134,18 @@ def make_invalid_path_error(cls):

@classmethod
def make_no_target_error(cls):
"""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",
Expand All @@ -171,6 +154,18 @@ def make_no_target_error(cls):

@classmethod
def make_invalid_value_error(cls):
"""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",
Expand All @@ -179,6 +174,14 @@ def make_invalid_value_error(cls):

@classmethod
def make_invalid_version_error(cls):
"""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",
Expand All @@ -187,6 +190,19 @@ def make_invalid_version_error(cls):

@classmethod
def make_sensitive_error(cls):
"""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",
Expand Down

0 comments on commit 3844dbf

Please sign in to comment.