Handlers#
The SCIM operations, served by calling a service and a storage in turn.
- class scim2_server.handler.ScimHandler(service: ScimService, storage: ScimStorage)[source]#
Serve the SCIM operations, by calling the steps of a service and a storage in turn.
Each method serves one SCIM operation: it takes a
ScimRequest, and returns itsScimResponse.handle()serves any request, by calling the method of its operation. A failure raises aSCIMException, thatScimService.error_responseturns into a response. Any other exception is a bug.- handle(request: ScimRequest) ScimResponse[source]#
Serve a request with the method of its operation (RFC 7644 §3.2).
- Raises:
NotFoundException – When the path matches no route.
MethodNotAllowedException – When the endpoint does not support the method.
NotImplementedException – When the request is on
/Meand the service does not overrideme_target().
- create(request: ScimRequest) ScimResponse[source]#
Create a resource (RFC 7644 §3.3).
- query(request: ScimRequest) ScimResponse[source]#
Read a resource (RFC 7644 §3.4.1).
- replace(request: ScimRequest) ScimResponse[source]#
Replace a resource (RFC 7644 §3.5.1).
- patch(request: ScimRequest) ScimResponse[source]#
Modify a resource (RFC 7644 §3.5.2).
- delete(request: ScimRequest) ScimResponse[source]#
Delete a resource (RFC 7644 §3.6).
- replace_resource(resource_type: ResourceType, current: Resource, replacement: Resource, conditions: Conditions) Resource[source]#
Apply a validated replacement to a stored resource, and return the stored result.
- patch_resource(resource_type: ResourceType, resource_id: str, patch_op: PatchOp[Any], conditions: Conditions) Resource[source]#
Apply a validated PATCH to a stored resource, and return the stored result.
- delete_resource(resource_type: ResourceType, resource_id: str, conditions: Conditions) None[source]#
Delete a stored resource once its conditions are met.
- search(request: ScimRequest) ScimResponse[source]#
Search with GET, on a resource type or at the root (RFC 7644 §3.4.2).
- search_with_body(request: ScimRequest) ScimResponse[source]#
Search with POST on “.search”, on a resource type or at the root (RFC 7644 §3.4.3).
- bulk(request: ScimRequest) ScimResponse[source]#
Run a bulk request (RFC 7644 §3.7).
- run_bulk_step(request: ScimRequest, plan: BulkPlan, step: BulkStep) tuple[dict[str, Any], Resource | None][source]#
Apply one step of a bulk request.
The step resolves the references of the operation, locates it and authorizes it. An operation that failed its validation then keeps its error.
- Returns:
The outcome of the step, and the resource it created or updated.
- apply_bulk_operation(resource_type: ResourceType, operation: BulkOperation[Resource]) Resource | None[source]#
Apply a validated bulk operation, and return the resource it acted on.
The data of the operation is already validated, in the context of the request the operation stands for.
- service_provider_config(request: ScimRequest) ScimResponse[source]#
Serve the ServiceProviderConfig endpoint (RFC 7644 §4).
- resource_types(request: ScimRequest) ScimResponse[source]#
Serve the ResourceTypes endpoint (RFC 7644 §4).
- resource_type(request: ScimRequest) ScimResponse[source]#
Serve one resource type (RFC 7644 §4).
- schemas(request: ScimRequest) ScimResponse[source]#
Serve the Schemas endpoint (RFC 7644 §4).
- schema(request: ScimRequest) ScimResponse[source]#
Serve one schema (RFC 7644 §4).
- class scim2_server.handler.AsyncScimHandler(service: ScimService, storage: AsyncScimStorage)[source]#
The asynchronous variant of
ScimHandler, over anAsyncScimStorage.It calls the same steps of the same service, and awaits the storage between them.
- async handle(request: ScimRequest) ScimResponse[source]#
Serve a request with the method of its operation (RFC 7644 §3.2).
- Raises:
NotFoundException – When the path matches no route.
MethodNotAllowedException – When the endpoint does not support the method.
NotImplementedException – When the request is on
/Meand the service does not overrideme_target().
- async create(request: ScimRequest) ScimResponse[source]#
Create a resource (RFC 7644 §3.3).
- async query(request: ScimRequest) ScimResponse[source]#
Read a resource (RFC 7644 §3.4.1).
- async replace(request: ScimRequest) ScimResponse[source]#
Replace a resource (RFC 7644 §3.5.1).
- async patch(request: ScimRequest) ScimResponse[source]#
Modify a resource (RFC 7644 §3.5.2).
- async delete(request: ScimRequest) ScimResponse[source]#
Delete a resource (RFC 7644 §3.6).
- async replace_resource(resource_type: ResourceType, current: Resource, replacement: Resource, conditions: Conditions) Resource[source]#
Apply a validated replacement to a stored resource, and return the stored result.
- async patch_resource(resource_type: ResourceType, resource_id: str, patch_op: PatchOp[Any], conditions: Conditions) Resource[source]#
Apply a validated PATCH to a stored resource, and return the stored result.
- async delete_resource(resource_type: ResourceType, resource_id: str, conditions: Conditions) None[source]#
Delete a stored resource once its conditions are met.
- async search(request: ScimRequest) ScimResponse[source]#
Search with GET, on a resource type or at the root (RFC 7644 §3.4.2).
- async search_with_body(request: ScimRequest) ScimResponse[source]#
Search with POST on “.search”, on a resource type or at the root (RFC 7644 §3.4.3).
- async bulk(request: ScimRequest) ScimResponse[source]#
Run a bulk request (RFC 7644 §3.7).
- async run_bulk_step(request: ScimRequest, plan: BulkPlan, step: BulkStep) tuple[dict[str, Any], Resource | None][source]#
Apply one step of a bulk request.
The step resolves the references of the operation, locates it and authorizes it. An operation that failed its validation then keeps its error.
- Returns:
The outcome of the step, and the resource it created or updated.
- async apply_bulk_operation(resource_type: ResourceType, operation: BulkOperation[Resource]) Resource | None[source]#
Apply a validated bulk operation, and return the resource it acted on.
The data of the operation is already validated, in the context of the request the operation stands for.
- async service_provider_config(request: ScimRequest) ScimResponse[source]#
Serve the ServiceProviderConfig endpoint (RFC 7644 §4).
- async resource_types(request: ScimRequest) ScimResponse[source]#
Serve the ResourceTypes endpoint (RFC 7644 §4).
- async resource_type(request: ScimRequest) ScimResponse[source]#
Serve one resource type (RFC 7644 §4).
- async schemas(request: ScimRequest) ScimResponse[source]#
Serve the Schemas endpoint (RFC 7644 §4).
- async schema(request: ScimRequest) ScimResponse[source]#
Serve one schema (RFC 7644 §4).