from enum import Enum
from typing import Annotated
from typing import Any
from pydantic import Field
from pydantic import PlainSerializer
from ..attributes import ComplexAttribute
from ..path import URN
from ..utils import _int_to_str
from .message import Message
[docs]
class BulkOperation(ComplexAttribute):
[docs]
class Method(str, Enum):
post = "POST"
put = "PUT"
patch = "PATCH"
delete = "DELETE"
method: Method | None = None
"""The HTTP method of the current operation."""
bulk_id: str | None = None
"""The transient identifier of a newly created resource, unique within a
bulk request and created by the client."""
version: str | None = None
"""The current resource version."""
path: str | None = None
"""The resource's relative path to the SCIM service provider's root."""
data: Any | None = None
"""The resource data as it would appear for a single SCIM POST, PUT, or
PATCH operation."""
location: str | None = None
"""The resource endpoint URL."""
response: Any | None = None
"""The HTTP response body for the specified request operation."""
status: Annotated[int | None, PlainSerializer(_int_to_str)] = None
"""The HTTP response status code for the requested operation."""
[docs]
class BulkRequest(Message):
"""Bulk request as defined in :rfc:`RFC7644 §3.7 <7644#section-3.7>`.
.. todo::
The models for Bulk operations are defined, but their behavior is not implemented nor tested yet.
"""
__schema__ = URN("urn:ietf:params:scim:api:messages:2.0:BulkRequest")
fail_on_errors: int | None = None
"""An integer specifying the number of errors that the service provider
will accept before the operation is terminated and an error response is
returned."""
operations: list[BulkOperation] | None = Field(
None, serialization_alias="Operations"
)
"""Defines operations within a bulk job."""
[docs]
class BulkResponse(Message):
"""Bulk response as defined in :rfc:`RFC7644 §3.7 <7644#section-3.7>`.
.. todo::
The models for Bulk operations are defined, but their behavior is not implemented nor tested yet.
"""
__schema__ = URN("urn:ietf:params:scim:api:messages:2.0:BulkResponse")
operations: list[BulkOperation] | None = Field(
None, serialization_alias="Operations"
)
"""Defines operations within a bulk job."""